diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-05-24 00:36:57 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-05-24 00:58:02 +0300 |
commit | 5b9e801e819b6daf1804874ed962bc2f1650c8da (patch) | |
tree | dd35d78ef4c0a04e346c7c0a9e1e7806899f1ddc /spec/services/ci | |
parent | 52527be4387cb978402a330f2e4de96e586a62db (diff) |
Sanity check pipeline sha before saving merge request head pipeline
Diffstat (limited to 'spec/services/ci')
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index b536103ed65..c31b3d63676 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -58,7 +58,7 @@ describe Ci::CreatePipelineService, services: true do end context 'when merge request target project is different from source project' do - let!(:target_project) { create(:empty_project) } + let!(:target_project) { create(:project) } let!(:forked_project_link) { create(:forked_project_link, forked_to_project: project, forked_from_project: target_project) } it 'updates head pipeline for merge request' do @@ -70,6 +70,17 @@ describe Ci::CreatePipelineService, services: true do expect(merge_request.reload.head_pipeline).to eq(head_pipeline) end end + + context 'when merge request head commit sha does not match pipeline sha' do + it 'does not update merge request head pipeline' do + merge_request = create(:merge_request, source_branch: 'master', target_branch: "branch_1", source_project: project) + allow_any_instance_of(MergeRequestDiff).to receive(:head_commit).and_return(double(id: 1234)) + + pipeline + + expect(merge_request.reload.head_pipeline).to be_nil + end + end end context 'auto-cancel enabled' do |