From 9d372d0da6719a10c41a7021356961e00f9dd23e Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 20 Nov 2017 18:29:59 +0900 Subject: Add a test --- spec/workers/pipeline_schedule_worker_spec.rb | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/spec/workers/pipeline_schedule_worker_spec.rb b/spec/workers/pipeline_schedule_worker_spec.rb index 75197039f5a..88b740b7a12 100644 --- a/spec/workers/pipeline_schedule_worker_spec.rb +++ b/spec/workers/pipeline_schedule_worker_spec.rb @@ -22,25 +22,32 @@ describe PipelineScheduleWorker do end context 'when there is a scheduled pipeline within next_run_at' do - it 'creates a new pipeline' do - expect { subject }.to change { project.pipelines.count }.by(1) - expect(Ci::Pipeline.last).to be_schedule + shared_examples 'successful scheduling' do + it 'creates a new pipeline' do + expect { subject }.to change { project.pipelines.count }.by(1) + + pipeline_schedule.reload + expect(Ci::Pipeline.last).to be_schedule + expect(pipeline_schedule.next_run_at).to be > Time.now + expect(pipeline_schedule).to eq(project.pipelines.last.pipeline_schedule) + expect(pipeline_schedule).to be_active + end end - it 'updates the next_run_at field' do - subject + it_behaves_like 'successful scheduling' - expect(pipeline_schedule.reload.next_run_at).to be > Time.now - end - - it 'sets the schedule on the pipeline' do - subject + context 'when the latest commit contains [ci skip]' do + before do + allow_any_instance_of(Ci::Pipeline) + .to receive(:git_commit_message) + .and_return('some commit [ci skip]') + end - expect(project.pipelines.last.pipeline_schedule).to eq(pipeline_schedule) + it_behaves_like 'successful scheduling' end end - context 'inactive schedule' do + context 'when the schedule is deactivated' do before do pipeline_schedule.deactivate! end -- cgit v1.2.1