Commit 065304dd authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'sh-fix-mr-redirects' into 'master'

Fix merge request redirects going to /commits page

See merge request gitlab-org/gitlab!16705
parents 3a64c110 934eb348
......@@ -239,8 +239,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
resources :merge_requests, concerns: :awardable, except: [:new, :create], constraints: { id: /\d+/ } do
resources :merge_requests, concerns: :awardable, except: [:new, :create, :show], constraints: { id: /\d+/ } do
member do
get :show # Insert this first to ensure redirections using merge_requests#show match this route
get :commit_change_content
post :merge
post :cancel_auto_merge
......
---
title: Fix merge request redirects going to /commits page
merge_request: 16705
author:
type: fixed
......@@ -78,6 +78,40 @@ describe Projects::MergeRequestsController do
expect(response).to be_successful
end
end
context 'when project has moved' do
let(:new_project) { create(:project) }
before do
project.route.destroy
new_project.redirect_routes.create!(path: project.full_path)
new_project.add_developer(user)
end
it 'redirects from an old merge request correctly' do
get :show,
params: {
namespace_id: project.namespace,
project_id: project,
id: merge_request
}
expect(response).to redirect_to(project_merge_request_path(new_project, merge_request))
expect(response).to have_gitlab_http_status(302)
end
it 'redirects from an old merge request commits correctly' do
get :commits,
params: {
namespace_id: project.namespace,
project_id: project,
id: merge_request
}
expect(response).to redirect_to(commits_project_merge_request_path(new_project, merge_request))
expect(response).to have_gitlab_http_status(302)
end
end
end
context 'when user is setting notes filters' do
......
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