2020-03-13 00:09:34 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-26 09:08:59 +00:00
|
|
|
RSpec.describe X509CertificateRevokeWorker do
|
2020-03-13 00:09:34 +00:00
|
|
|
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
|