summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2017-02-04 00:00:26 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2017-02-04 00:00:26 +1100
commit63dac85385c6f82db6c6465876d76f67173ebc3b (patch)
tree69cca8082e1710826cd0f9f815fa44a04b9cb25f
parentfd46fb1cd9cc1fdf826d31261aa594baa38d4898 (diff)
downloadgitlab-ce-63dac85385c6f82db6c6465876d76f67173ebc3b.tar.gz
Fixed redirection from http://someproject.git to http://someproject
-rw-r--r--app/controllers/projects/application_controller.rb2
-rw-r--r--changelogs/unreleased/git_to_html_redirection.yml4
-rw-r--r--spec/controllers/projects_controller_spec.rb11
3 files changed, 16 insertions, 1 deletions
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index b2ff36f6538..f9d550ffb85 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -18,7 +18,7 @@ class Projects::ApplicationController < ApplicationController
# to
# localhost/group/project
#
- if id =~ /\.git\Z/
+ if params[:format] == 'git'
redirect_to request.original_url.gsub(/\.git\/?\Z/, '')
return
end
diff --git a/changelogs/unreleased/git_to_html_redirection.yml b/changelogs/unreleased/git_to_html_redirection.yml
new file mode 100644
index 00000000000..b2959c02c07
--- /dev/null
+++ b/changelogs/unreleased/git_to_html_redirection.yml
@@ -0,0 +1,4 @@
+---
+title: Redirect http://someproject.git to http://someproject
+merge_request:
+author: blackst0ne
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 9323f723bdb..e7aa8745b99 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -213,6 +213,17 @@ describe ProjectsController do
expect(response.status).to eq 404
end
end
+
+ context "redirection from http://someproject.git" do
+ it 'redirects to project page (format.html)' do
+ project = create(:project, :public)
+
+ get :show, namespace_id: project.namespace.path, id: project.path, format: :git
+
+ expect(response).to have_http_status(302)
+ expect(response).to redirect_to(namespace_project_path)
+ end
+ end
end
describe "#update" do