Commit 937e0948 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-handle-no-latest-pipeline' into 'master'

Gracefully handle missing latest CI pipeline

Closes #212552

See merge request gitlab-org/gitlab!28263
parents f0f05d2d 0f362b13
......@@ -13,6 +13,7 @@ class Projects::PipelinesController < Projects::ApplicationController
before_action do
push_frontend_feature_flag(:junit_pipeline_view)
end
before_action :ensure_pipeline, only: [:show]
around_action :allow_gitaly_ref_name_caching, only: [:index, :show]
......@@ -214,6 +215,10 @@ class Projects::PipelinesController < Projects::ApplicationController
params.require(:pipeline).permit(:ref, variables_attributes: %i[key variable_type secret_value])
end
def ensure_pipeline
render_404 unless pipeline
end
# rubocop: disable CodeReuse/ActiveRecord
def pipeline
@pipeline ||= if params[:id].blank? && params[:latest]
......
---
title: Gracefully handle missing latest CI pipeline
merge_request: 28263
author:
type: fixed
......@@ -923,10 +923,18 @@ describe Projects::PipelinesController do
end
context 'ref provided' do
render_views
before do
create(:ci_pipeline, ref: 'master', project: project)
end
it 'shows a 404 if no pipeline exists' do
get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: 'non-existence' }
expect(response).to have_gitlab_http_status(:not_found)
end
it 'shows the latest pipeline for the provided ref' do
get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: branch_secondary.name }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment