diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-10 21:07:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-10 21:07:43 +0300 |
commit | 6f0f893bd87535b61e0ecb1ce069eaa7fcb9e5be (patch) | |
tree | 8af92b29c838e9af2fd70f9a4a2314a08f4af922 /spec/support/shared_examples/workers | |
parent | 8b1228b0d409d7751f01d9fb72ebfbbf62399486 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples/workers')
-rw-r--r-- | spec/support/shared_examples/workers/self_monitoring_shared_examples.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/support/shared_examples/workers/self_monitoring_shared_examples.rb b/spec/support/shared_examples/workers/self_monitoring_shared_examples.rb new file mode 100644 index 00000000000..89c0841fbd6 --- /dev/null +++ b/spec/support/shared_examples/workers/self_monitoring_shared_examples.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# This shared_example requires the following variables: +# let(:service_class) { Gitlab::DatabaseImporters::SelfMonitoring::Project::DeleteService } +# let(:service) { instance_double(service_class) } +RSpec.shared_examples 'executes service' do + before do + allow(service_class).to receive(:new) { service } + end + + it 'runs the service' do + expect(service).to receive(:execute) + + subject.perform + end +end + +RSpec.shared_examples 'returns in_progress based on Sidekiq::Status' do + it 'returns true when job is enqueued' do + jid = described_class.perform_async + + expect(described_class.in_progress?(jid)).to eq(true) + end + + it 'returns false when job does not exist' do + expect(described_class.in_progress?('fake_jid')).to eq(false) + end +end |