Base pipeline must be from target branch
This commit is contained in:
parent
ecb1411fbb
commit
b079a6b6bb
|
@ -1322,7 +1322,7 @@ class MergeRequest < ActiveRecord::Base
|
|||
def base_pipeline
|
||||
@base_pipeline ||= project.ci_pipelines
|
||||
.order(id: :desc)
|
||||
.find_by(sha: diff_base_sha)
|
||||
.find_by(sha: diff_base_sha, ref: target_branch)
|
||||
end
|
||||
|
||||
def discussions_rendered_on_frontend?
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Ensure the base pipeline of a Merge Request belongs to its target branch
|
||||
merge_request: 25226
|
||||
author:
|
||||
type: fixed
|
|
@ -2604,8 +2604,9 @@ describe MergeRequest do
|
|||
|
||||
let!(:first_pipeline) { create(:ci_pipeline_without_jobs, pipeline_arguments) }
|
||||
let!(:last_pipeline) { create(:ci_pipeline_without_jobs, pipeline_arguments) }
|
||||
let!(:last_pipeline_with_other_ref) { create(:ci_pipeline_without_jobs, pipeline_arguments.merge(ref: 'other')) }
|
||||
|
||||
it 'returns latest pipeline' do
|
||||
it 'returns latest pipeline for the target branch' do
|
||||
expect(merge_request.base_pipeline).to eq(last_pipeline)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue