summaryrefslogtreecommitdiff
path: root/spec/workers/x509_certificate_revoke_worker_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 00:09:34 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 00:09:34 +0000
commit3cd08f4bf96cda3e9d3abf233095107832b17c20 (patch)
treedc09a618783a79d70f2a404374d4b850ccf9cc84 /spec/workers/x509_certificate_revoke_worker_spec.rb
parentdd4bee69b7d55620f7dc9db8c36b478bd4959755 (diff)
downloadgitlab-ce-3cd08f4bf96cda3e9d3abf233095107832b17c20.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/x509_certificate_revoke_worker_spec.rb')
-rw-r--r--spec/workers/x509_certificate_revoke_worker_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/workers/x509_certificate_revoke_worker_spec.rb b/spec/workers/x509_certificate_revoke_worker_spec.rb
new file mode 100644
index 00000000000..1e0cbf61267
--- /dev/null
+++ b/spec/workers/x509_certificate_revoke_worker_spec.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe X509CertificateRevokeWorker do
+ describe '#perform' do
+ context 'with a revoked certificate' do
+ subject { described_class.new }
+
+ let(:x509_certificate) { create(:x509_certificate, certificate_status: :revoked) }
+ let(:job_args) { x509_certificate.id }
+
+ include_examples 'an idempotent worker' do
+ it 'executes the revoke service' do
+ spy_service = X509CertificateRevokeService.new
+
+ allow(X509CertificateRevokeService).to receive(:new) { spy_service }
+
+ expect(spy_service).to receive(:execute)
+ .exactly(IdempotentWorkerHelper::WORKER_EXEC_TIMES).times
+ .with(x509_certificate)
+ .and_call_original
+
+ subject
+ end
+ end
+
+ it 'executes the revoke service' do
+ spy_service = X509CertificateRevokeService.new
+
+ allow(X509CertificateRevokeService).to receive(:new) { spy_service }
+
+ expect_next_instance_of(X509CertificateRevokeService) do |service|
+ expect(service).to receive(:execute).with(x509_certificate)
+ end
+
+ subject
+ end
+ end
+ end
+end