summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAlexis Reigel <mail@koffeinfrei.org>2017-06-22 14:18:01 +0200
committerAlexis Reigel <mail@koffeinfrei.org>2017-07-27 15:43:36 +0200
commit9816856d055b33de9c47d9e3b73c4acb99c5b5e6 (patch)
treeae3b0c3b89c008830eb42e2d89713247c6e4a7be /spec
parent9d30a80d24a583aad267a8a11f685058eab2c864 (diff)
downloadgitlab-ce-9816856d055b33de9c47d9e3b73c4acb99c5b5e6.tar.gz
perform signature update in sidekiq worker
Diffstat (limited to 'spec')
-rw-r--r--spec/features/commits_spec.rb14
-rw-r--r--spec/workers/invalid_gpg_signature_update_worker_spec.rb36
2 files changed, 46 insertions, 4 deletions
diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb
index 8f89b465160..7635e87e838 100644
--- a/spec/features/commits_spec.rb
+++ b/spec/features/commits_spec.rb
@@ -223,7 +223,9 @@ describe 'Commits' do
user = create :user, email: 'unrelated.user@example.org'
project.team << [user, :master]
- create :gpg_key, key: GpgHelpers::User1.public_key, user: user
+ Sidekiq::Testing.inline! do
+ create :gpg_key, key: GpgHelpers::User1.public_key, user: user
+ end
login_with(user)
@@ -235,8 +237,10 @@ describe 'Commits' do
end
# user changes his email which makes the gpg key verified
- user.skip_reconfirmation!
- user.update_attributes!(email: GpgHelpers::User1.emails.first)
+ Sidekiq::Testing.inline! do
+ user.skip_reconfirmation!
+ user.update_attributes!(email: GpgHelpers::User1.emails.first)
+ end
visit namespace_project_commits_path(project.namespace, project, :master)
@@ -260,7 +264,9 @@ describe 'Commits' do
end
# user adds the gpg key which makes the signature valid
- create :gpg_key, key: GpgHelpers::User1.public_key, user: user
+ Sidekiq::Testing.inline! do
+ create :gpg_key, key: GpgHelpers::User1.public_key, user: user
+ end
visit namespace_project_commits_path(project.namespace, project, :master)
diff --git a/spec/workers/invalid_gpg_signature_update_worker_spec.rb b/spec/workers/invalid_gpg_signature_update_worker_spec.rb
new file mode 100644
index 00000000000..8d568076e1a
--- /dev/null
+++ b/spec/workers/invalid_gpg_signature_update_worker_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe InvalidGpgSignatureUpdateWorker do
+ context 'when GpgKey is found' do
+ it 'calls NotificationService.new.run' do
+ gpg_key = create(:gpg_key)
+ invalid_signature_updater = double(:invalid_signature_updater)
+
+ expect(Gitlab::Gpg::InvalidGpgSignatureUpdater).to receive(:new).with(gpg_key).and_return(invalid_signature_updater)
+ expect(invalid_signature_updater).to receive(:run)
+
+ described_class.new.perform(gpg_key.id)
+ end
+ end
+
+ context 'when GpgKey is not found' do
+ let(:nonexisting_gpg_key_id) { -1 }
+
+ it 'logs InvalidGpgSignatureUpdateWorker process skipping' do
+ expect(Rails.logger).to receive(:error)
+ .with("InvalidGpgSignatureUpdateWorker: couldn't find gpg_key with ID=-1, skipping job")
+
+ described_class.new.perform(nonexisting_gpg_key_id)
+ end
+
+ it 'does not raise errors' do
+ expect { described_class.new.perform(nonexisting_gpg_key_id) }.not_to raise_error
+ end
+
+ it 'does not call NotificationService.new.run' do
+ expect(Gitlab::Gpg::InvalidGpgSignatureUpdater).not_to receive(:new)
+
+ described_class.new.perform(nonexisting_gpg_key_id)
+ end
+ end
+end