From eb1956c504f876263bcb3cbea2ddb43598e8a20d Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 7 Dec 2018 23:38:09 +0900 Subject: Fix MR pipelines run on only: refex --- spec/services/ci/create_pipeline_service_spec.rb | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'spec/services') diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index ccc6b0ef1c7..8b8021ecbc8 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -810,6 +810,64 @@ describe Ci::CreatePipelineService do end end end + + context "when config uses regular expression for only keyword" do + let(:config) do + { + build: { + stage: 'build', + script: 'echo', + only: ["/^#{ref_name}$/"] + } + } + end + + context 'when merge request is specified' do + let(:merge_request) do + create(:merge_request, + source_project: project, + source_branch: ref_name, + target_project: project, + target_branch: 'master') + end + + it 'does not create a merge request pipeline' do + expect(pipeline).not_to be_persisted + + expect(pipeline.errors[:base]) + .to eq(['No stages / jobs for this pipeline.']) + end + end + end + + context "when config has 'except: [tags]'" do + let(:config) do + { + build: { + stage: 'build', + script: 'echo', + except: ['tags'] + } + } + end + + context 'when merge request is specified' do + let(:merge_request) do + create(:merge_request, + source_project: project, + source_branch: ref_name, + target_project: project, + target_branch: 'master') + end + + it 'does not create a merge request pipeline' do + expect(pipeline).not_to be_persisted + + expect(pipeline.errors[:base]) + .to eq(['No stages / jobs for this pipeline.']) + end + end + end end context 'when source is web' do -- cgit v1.2.3