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:
authorStan Hu <stanhu@gmail.com>2017-12-03 09:55:49 +0300
committerStan Hu <stanhu@gmail.com>2017-12-13 02:07:23 +0300
commit8e7f19c60bea4eec86844be1e0db12ebf30f105e (patch)
treea86172a9287a4e85900236e3007408d7a8ae2fc2 /spec/workers/run_pipeline_schedule_worker_spec.rb
parentad1ce1238e8adfb1d10529a99ffd2b298bde3fb5 (diff)
Add button to run scheduled pipeline immediately
Closes #38741
Diffstat (limited to 'spec/workers/run_pipeline_schedule_worker_spec.rb')
-rw-r--r--spec/workers/run_pipeline_schedule_worker_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/workers/run_pipeline_schedule_worker_spec.rb b/spec/workers/run_pipeline_schedule_worker_spec.rb
new file mode 100644
index 00000000000..4a88ac51f62
--- /dev/null
+++ b/spec/workers/run_pipeline_schedule_worker_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe RunPipelineScheduleWorker do
+ describe '#perform' do
+ let(:project) { create(:project) }
+ let(:worker) { described_class.new }
+ let(:user) { create(:user) }
+ let(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project ) }
+
+ context 'when a project not found' do
+ it 'does not call the Service' do
+ expect(Ci::CreatePipelineService).not_to receive(:new)
+ expect { worker.perform(100000, user.id) }.to raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+
+ context 'when a user not found' do
+ it 'does not call the Service' do
+ expect(Ci::CreatePipelineService).not_to receive(:new)
+ expect { worker.perform(pipeline_schedule.id, 10000) }.to raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+
+ context 'when everything is ok' do
+ let(:project) { create(:project) }
+ let(:create_pipeline_service) { instance_double(Ci::CreatePipelineService) }
+
+ it 'calls the Service' do
+ expect(Ci::CreatePipelineService).to receive(:new).with(project, user, ref: pipeline_schedule.ref).and_return(create_pipeline_service)
+ expect(create_pipeline_service).to receive(:execute).with(:schedule, ignore_skip_ci: true, save_on_errors: false, schedule: pipeline_schedule)
+
+ worker.perform(pipeline_schedule.id, user.id)
+ end
+ end
+ end
+end