summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-11-28 20:09:27 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-11-28 20:09:27 +0000
commit99d143fb2e67b1015166d54cb6cac5c197355a10 (patch)
tree3928aee24c6b8a36c77e321398ea93c7d9db7955 /spec/workers
parent1ce27c7d78f0833985ef82b0018064d3c821b9fe (diff)
parentac87bd0c113e5265d7913e13c005850a4f6bf4c3 (diff)
downloadgitlab-ce-99d143fb2e67b1015166d54cb6cac5c197355a10.tar.gz
Merge branch '38962-automatically-run-a-pipeline-when-auto-devops-is-turned-on-in-project-settings' into 'master'
Add checkbox to automatically run a pipeline when Auto DevOps is turned on in project settings Closes #38962 See merge request gitlab-org/gitlab-ce!15380
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/create_pipeline_worker_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/workers/create_pipeline_worker_spec.rb b/spec/workers/create_pipeline_worker_spec.rb
new file mode 100644
index 00000000000..02cb0f46cb4
--- /dev/null
+++ b/spec/workers/create_pipeline_worker_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe CreatePipelineWorker do
+ describe '#perform' do
+ let(:worker) { described_class.new }
+
+ context 'when a project not found' do
+ it 'does not call the Service' do
+ expect(Ci::CreatePipelineService).not_to receive(:new)
+ expect { worker.perform(99, create(:user).id, 'master', :web) }.to raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+
+ context 'when a user not found' do
+ let(:project) { create(:project) }
+
+ it 'does not call the Service' do
+ expect(Ci::CreatePipelineService).not_to receive(:new)
+ expect { worker.perform(project.id, 99, project.default_branch, :web) }.to raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+
+ context 'when everything is ok' do
+ let(:project) { create(:project) }
+ let(:user) { create(:user) }
+ let(:create_pipeline_service) { instance_double(Ci::CreatePipelineService) }
+
+ it 'calls the Service' do
+ expect(Ci::CreatePipelineService).to receive(:new).with(project, user, ref: project.default_branch).and_return(create_pipeline_service)
+ expect(create_pipeline_service).to receive(:execute).with(:web, any_args)
+
+ worker.perform(project.id, user.id, project.default_branch, :web)
+ end
+ end
+ end
+end