Skip to content
Snippets Groups Projects
Commit 740f64c7 authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by GitLab Release Tools Bot
Browse files

Merge branch 'fix-udpate-head-pipeline-method' into 'master'

Fix unexpected exception by failure of finding an actual head pipeline

Closes #56113

See merge request gitlab-org/gitlab-ce!24257

(cherry picked from commit 3ce491c5)

1c248cd4 Fix unexpected exception by failed to find an actual head pipeline
parent f623c2f2
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1102,9 +1102,10 @@ class MergeRequest < ActiveRecord::Base
end
 
def update_head_pipeline
self.head_pipeline = find_actual_head_pipeline
update_column(:head_pipeline_id, head_pipeline.id) if head_pipeline_id_changed?
find_actual_head_pipeline.try do |pipeline|
self.head_pipeline = pipeline
update_column(:head_pipeline_id, head_pipeline.id) if head_pipeline_id_changed?
end
end
 
def merge_request_pipeline_exists?
Loading
Loading
---
title: Fix unexpected exception by failure of finding an actual head pipeline
merge_request: 24257
author:
type: fixed
Loading
Loading
@@ -1390,6 +1390,23 @@ describe MergeRequest do
.to change { merge_request.reload.head_pipeline }
.from(nil).to(pipeline)
end
context 'when merge request has already had head pipeline' do
before do
merge_request.update!(head_pipeline: pipeline)
end
context 'when failed to find an actual head pipeline' do
before do
allow(merge_request).to receive(:find_actual_head_pipeline) { }
end
it 'does not update the current head pipeline' do
expect { subject }
.not_to change { merge_request.reload.head_pipeline }
end
end
end
end
 
context 'when there are no pipelines with the diff head sha' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment