summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2017-05-03 15:43:26 +0200
committerJames Lopez <james@jameslopez.es>2017-05-03 15:43:26 +0200
commite81ea165ba738fedab07d5e20423856e004e2594 (patch)
treef08ef0c7ca78c29e77b812227481425beca19635
parent7ac89d05dbf6c932e9cb6e87cc64c46e015a22d5 (diff)
downloadgitlab-ce-e81ea165ba738fedab07d5e20423856e004e2594.tar.gz
added worker spec
-rw-r--r--spec/workers/propagate_project_service_worker_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/workers/propagate_project_service_worker_spec.rb b/spec/workers/propagate_project_service_worker_spec.rb
new file mode 100644
index 00000000000..ce01a663a8f
--- /dev/null
+++ b/spec/workers/propagate_project_service_worker_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe PruneOldEventsWorker do
+ describe '#perform' do
+ let!(:service_template) do
+ PushoverService.create(
+ template: true,
+ properties: {
+ device: 'MyDevice',
+ sound: 'mic',
+ priority: 4,
+ api_key: '123456789'
+ })
+ end
+
+ let!(:project) { create(:empty_project) }
+
+ it 'creates services for projects' do
+ expect { subject.perform }.to change { Service.count }.by(1)
+ end
+
+ it 'does not create the service if it exists already' do
+ Service.build_from_template(project.id, service_template).save!
+
+ expect { subject.perform }.not_to change { Service.count }
+ end
+
+ it 'creates the service containing the template attributes' do
+ subject.perform
+
+ service = Service.find_by(service_template.merge(project_id: project.id, template: false))
+
+ expect(service).not_to be_nil
+ end
+ end
+end