diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-06-22 14:18:01 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-27 15:43:36 +0200 |
commit | 9816856d055b33de9c47d9e3b73c4acb99c5b5e6 (patch) | |
tree | ae3b0c3b89c008830eb42e2d89713247c6e4a7be /spec/workers | |
parent | 9d30a80d24a583aad267a8a11f685058eab2c864 (diff) | |
download | gitlab-ce-9816856d055b33de9c47d9e3b73c4acb99c5b5e6.tar.gz |
perform signature update in sidekiq worker
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/invalid_gpg_signature_update_worker_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
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 |