diff options
Diffstat (limited to 'spec/services/merge_requests')
-rw-r--r-- | spec/services/merge_requests/create_pipeline_service_spec.rb | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/spec/services/merge_requests/create_pipeline_service_spec.rb b/spec/services/merge_requests/create_pipeline_service_spec.rb index 576e8498e4d..25f5c54a413 100644 --- a/spec/services/merge_requests/create_pipeline_service_spec.rb +++ b/spec/services/merge_requests/create_pipeline_service_spec.rb @@ -62,13 +62,65 @@ describe MergeRequests::CreatePipelineService do end end - context 'when .gitlab-ci.yml does not have only: [merge_requests] keyword' do - let(:config) do - { rspec: { script: 'echo' } } + context 'when .gitlab-ci.yml does not use workflow:rules' do + context 'without only: [merge_requests] keyword' do + let(:config) do + { rspec: { script: 'echo' } } + end + + it 'does not create a pipeline' do + expect { subject }.not_to change { Ci::Pipeline.count } + end + end + + context 'with rules that specify creation on a tag' do + let(:config) do + { + rspec: { + script: 'echo', + rules: [{ if: '$CI_COMMIT_TAG' }] + } + } + end + + it 'does not create a pipeline' do + expect { subject }.not_to change { Ci::Pipeline.count } + end + end + end + + context 'when workflow:rules are specified' do + context 'when rules request creation on merge request' do + let(:config) do + { + workflow: { + rules: [{ if: '$CI_MERGE_REQUEST_ID' }] + }, + rspec: { script: 'echo' } + } + end + + it 'creates a detached merge request pipeline' do + expect { subject }.to change { Ci::Pipeline.count }.by(1) + + expect(subject).to be_persisted + expect(subject).to be_detached_merge_request_pipeline + end end - it 'does not create a pipeline' do - expect { subject }.not_to change { Ci::Pipeline.count } + context 'with rules do specify creation on a tag' do + let(:config) do + { + workflow: { + rules: [{ if: '$CI_COMMIT_TAG' }] + }, + rspec: { script: 'echo' } + } + end + + it 'does not create a pipeline' do + expect { subject }.not_to change { Ci::Pipeline.count } + end end end end |