Commit c17127d4 authored by Laura Montemayor's avatar Laura Montemayor Committed by lauraMon

Updates with feedback

parent fa5f9b1c
......@@ -19,7 +19,8 @@ class Projects::PipelinesController < Projects::ApplicationController
end
before_action :ensure_pipeline, only: [:show]
before_action :ensure_valid_scope, only: [:index]
# Will be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/225596
before_action :redirect_for_legacy_scope_filter, only: [:index], if: -> { request.format.html? }
around_action :allow_gitaly_ref_name_caching, only: [:index, :show]
......@@ -225,8 +226,10 @@ class Projects::PipelinesController < Projects::ApplicationController
render_404 unless pipeline
end
def ensure_valid_scope
redirect_to project_pipelines_path(project, status: params[:scope]) if %w[running pending].include?(params[:scope])
def redirect_for_legacy_scope_filter
return unless %w[running pending].include?(params[:scope])
redirect_to url_for(safe_params.except(:scope).merge(status: safe_params[:scope])), status: :moved_permanently
end
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -119,11 +119,11 @@ RSpec.describe Projects::PipelinesController do
end
end
context 'when scope is pending or running' do
context 'when user tries to access legacy scope via URL' do
it 'redirects to all pipelines with that status instead' do
get_pipelines_index_json(scope: 'running')
get_pipelines_index_html(scope: 'running')
expect(response).to redirect_to(project_pipelines_path(project, status: 'running'))
expect(response).to redirect_to(project_pipelines_path(project, status: 'running', format: :html))
end
end
......@@ -219,6 +219,14 @@ RSpec.describe Projects::PipelinesController do
end
end
def get_pipelines_index_html(params = {})
get :index, params: {
namespace_id: project.namespace,
project_id: project
}.merge(params),
format: :html
end
def get_pipelines_index_json(params = {})
get :index, params: {
namespace_id: project.namespace,
......
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