diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-06-28 15:51:36 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-06-28 19:24:40 -0300 |
commit | 34dbccb24b38c5a7c52641e7008f3ab53b25c66a (patch) | |
tree | 4b5121120fe3973729e546fd3e25a0a4f6106ea9 /spec/workers/propagate_service_template_worker_spec.rb | |
parent | e38af20cc6eae4f001fd98b0450f00f496a278d0 (diff) | |
download | gitlab-ce-34dbccb24b38c5a7c52641e7008f3ab53b25c66a.tar.gz |
Add helper methods to stub Gitlab::ExclusiveLease
Diffstat (limited to 'spec/workers/propagate_service_template_worker_spec.rb')
-rw-r--r-- | spec/workers/propagate_service_template_worker_spec.rb | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/spec/workers/propagate_service_template_worker_spec.rb b/spec/workers/propagate_service_template_worker_spec.rb index b8b65ead9b3..af1fb80a51d 100644 --- a/spec/workers/propagate_service_template_worker_spec.rb +++ b/spec/workers/propagate_service_template_worker_spec.rb @@ -1,29 +1,29 @@ require 'spec_helper' describe PropagateServiceTemplateWorker do - let!(:service_template) do - PushoverService.create( - template: true, - active: true, - properties: { - device: 'MyDevice', - sound: 'mic', - priority: 4, - user_key: 'asdf', - api_key: '123456789' - }) - end - - before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) - .and_return(true) - end + include ExclusiveLeaseHelpers describe '#perform' do it 'calls the propagate service with the template' do - expect(Projects::PropagateServiceTemplate).to receive(:propagate).with(service_template) + template = PushoverService.create( + template: true, + active: true, + properties: { + device: 'MyDevice', + sound: 'mic', + priority: 4, + user_key: 'asdf', + api_key: '123456789' + }) + + stub_exclusive_lease("propagate_service_template_worker:#{template.id}", + timeout: PropagateServiceTemplateWorker::LEASE_TIMEOUT) + + expect(Projects::PropagateServiceTemplate) + .to receive(:propagate) + .with(template) - subject.perform(service_template.id) + subject.perform(template.id) end end end |