Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-06-28 21:51:36 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-06-29 01:24:40 +0300
commit34dbccb24b38c5a7c52641e7008f3ab53b25c66a (patch)
tree4b5121120fe3973729e546fd3e25a0a4f6106ea9 /spec/workers/propagate_service_template_worker_spec.rb
parente38af20cc6eae4f001fd98b0450f00f496a278d0 (diff)
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.rb38
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