diff options
author | James Lopez <james@jameslopez.es> | 2017-05-04 12:13:33 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-05-04 12:13:33 +0200 |
commit | f81cf84035213002ce7931af6c3ffa917fe7fcbd (patch) | |
tree | 3393496e46cdacd5db03a2348dda8ed1a58a3d57 /spec/workers | |
parent | 2f7f1ce4e66db847414e2fc3de09556e75c51eb4 (diff) | |
download | gitlab-ce-f81cf84035213002ce7931af6c3ffa917fe7fcbd.tar.gz |
refactor worker into service
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/propagate_project_service_worker_spec.rb | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/spec/workers/propagate_project_service_worker_spec.rb b/spec/workers/propagate_project_service_worker_spec.rb index d525a8b4a23..c16e95bd49b 100644 --- a/spec/workers/propagate_project_service_worker_spec.rb +++ b/spec/workers/propagate_project_service_worker_spec.rb @@ -1,43 +1,29 @@ require 'spec_helper' describe PropagateProjectServiceWorker do - describe '#perform' 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 - - let!(:project) { create(:empty_project) } - - before do - allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). - and_return(true) - end - - it 'creates services for projects' do - expect { subject.perform(service_template.id) }.to change { Service.count }.by(1) - end + let!(:service_template) do + PushoverService.create( + template: true, + active: true, + properties: { + device: 'MyDevice', + sound: 'mic', + priority: 4, + user_key: 'asdf', + api_key: '123456789' + }) + end - it 'does not create the service if it exists already' do - Service.build_from_template(project.id, service_template).save! + before do + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). + and_return(true) + end - expect { subject.perform(service_template.id) }.not_to change { Service.count } - end + describe '#perform' do + it 'calls the propagate service with the template' do + expect(Projects::PropagateService).to receive(:propagate!).with(service_template) - it 'creates the service containing the template attributes' do subject.perform(service_template.id) - - service = Service.find_by(type: service_template.type, template: false) - - expect(service.properties).to eq(service_template.properties) end end end |