diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 15:08:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-13 15:08:49 +0300 |
commit | 1308dc5eb484ab0f8064989fc551ebdb4b1a7976 (patch) | |
tree | 614a93d9bf8df34ecfc25c02648329987fb21dde /spec/services/ci | |
parent | f0707f413ce49b5712fca236b950acbec029be1e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/ci')
-rw-r--r-- | spec/services/ci/create_cross_project_pipeline_service_spec.rb | 32 | ||||
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 50 |
2 files changed, 35 insertions, 47 deletions
diff --git a/spec/services/ci/create_cross_project_pipeline_service_spec.rb b/spec/services/ci/create_cross_project_pipeline_service_spec.rb index 8a1763b30ed..3625bc6ff41 100644 --- a/spec/services/ci/create_cross_project_pipeline_service_spec.rb +++ b/spec/services/ci/create_cross_project_pipeline_service_spec.rb @@ -148,6 +148,12 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do end context 'when "include" is provided' do + let(:file_content) do + YAML.dump( + rspec: { script: 'rspec' }, + echo: { script: 'echo' }) + end + shared_examples 'creates a child pipeline' do it 'creates only one new pipeline' do expect { service.execute(bridge) } @@ -189,9 +195,6 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do end before do - file_content = YAML.dump( - rspec: { script: 'rspec' }, - echo: { script: 'echo' }) upstream_project.repository.create_file( user, 'child-pipeline.yml', file_content, message: 'message', branch_name: 'master') @@ -218,6 +221,29 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do it_behaves_like 'creates a child pipeline' end + context 'when the parent is a merge request pipeline' do + let(:merge_request) { create(:merge_request, source_project: bridge.project, target_project: bridge.project) } + let(:file_content) do + YAML.dump( + workflow: { rules: [{ if: '$CI_MERGE_REQUEST_ID' }] }, + rspec: { script: 'rspec' }, + echo: { script: 'echo' }) + end + + before do + bridge.pipeline.update!(source: :merge_request_event, merge_request: merge_request) + end + + it_behaves_like 'creates a child pipeline' + + it 'propagates the merge request to the child pipeline' do + pipeline = service.execute(bridge) + + expect(pipeline.merge_request).to eq(merge_request) + expect(pipeline).to be_merge_request + end + end + context 'when upstream pipeline is a child pipeline' do let!(:pipeline_source) do create(:ci_sources_pipeline, diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index eb7e0c1c226..7745a78a806 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -1473,15 +1473,6 @@ describe Ci::CreatePipelineService do end end end - - context 'when merge request is not specified' do - let(:merge_request) { nil } - - it 'does not create a detached merge request pipeline' do - expect(pipeline).not_to be_persisted - expect(pipeline.errors[:merge_request]).to eq(["can't be blank"]) - end - end end context "when config does not have merge_requests keywords" do @@ -1518,17 +1509,6 @@ describe Ci::CreatePipelineService do .to eq(['No stages / jobs for this pipeline.']) end end - - context 'when merge request is not specified' do - let(:merge_request) { nil } - - it 'does not create a detached 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 uses regular expression for only keyword" do @@ -1623,6 +1603,7 @@ describe Ci::CreatePipelineService do context 'when source is web' do let(:source) { :web } + let(:merge_request) { nil } context "when config has merge_requests keywords" do let(:config) do @@ -1644,30 +1625,11 @@ describe Ci::CreatePipelineService do } end - context 'when merge request is specified' do - let(:merge_request) do - create(:merge_request, - source_project: project, - source_branch: Gitlab::Git.ref_name(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[:merge_request]).to eq(["must be blank"]) - end - end - - context 'when merge request is not specified' do - let(:merge_request) { nil } - - it 'creates a branch pipeline' do - expect(pipeline).to be_persisted - expect(pipeline).to be_web - expect(pipeline.merge_request).to be_nil - expect(pipeline.builds.order(:stage_id).pluck(:name)).to eq(%w[build pages]) - end + it 'creates a branch pipeline' do + expect(pipeline).to be_persisted + expect(pipeline).to be_web + expect(pipeline.merge_request).to be_nil + expect(pipeline.builds.order(:stage_id).pluck(:name)).to eq(%w[build pages]) end end end |