Commit eefe06ee authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch 'fix-projects-double-render' into 'master'

Fix double render in project's git URL redirect

See merge request gitlab-org/gitlab!62053
parents 0c7ef335 45512b2c
......@@ -510,7 +510,7 @@ class ProjectsController < Projects::ApplicationController
# `project` calls `find_routable!`, so this will trigger the usual not-found
# behaviour when the user isn't authorized to see the project
return unless project
return if project.nil? || performed?
redirect_to(request.original_url.sub(%r{\.git/?\Z}, ''))
end
......
......@@ -375,6 +375,23 @@ RSpec.describe ProjectsController do
end
end
context 'when project is moved and git format is requested' do
let(:old_path) { project.path + 'old' }
before do
project.redirect_routes.create!(path: "#{project.namespace.full_path}/#{old_path}")
project.add_developer(user)
sign_in(user)
end
it 'redirects to new project path' do
get :show, params: { namespace_id: project.namespace, id: old_path }, format: :git
expect(response).to redirect_to(project_path(project, format: :git))
end
end
context 'when the project is forked and has a repository', :request_store do
let(:public_project) { create(:project, :public, :repository) }
let(:other_user) { create(:user) }
......
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