Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jschatz1@gmail.com>2016-10-15 17:51:16 +0300
committerJacob Schatz <jschatz1@gmail.com>2016-10-15 17:51:16 +0300
commita65394f35cc83f342e9b2c654cfb32d3eb4c45e7 (patch)
tree30eefb73dbf767d42052d2f71bac52bab483b335
parent6f59f73c1e8a5dd7862e7b7ba8ebd9c59c1022fd (diff)
parent5cf10240f9d8736923c57ff35c5c4acab7de37dc (diff)
Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--config/routes.rb2
-rw-r--r--lib/extracts_path.rb17
-rw-r--r--spec/requests/git_http_spec.rb5
4 files changed, 18 insertions, 10 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index b3455e04c29..705824502eb 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -45,6 +45,10 @@ class ApplicationController < ActionController::Base
redirect_to request.referer.present? ? :back : default, options
end
+ def not_found
+ render_404
+ end
+
protected
# This filter handles both private tokens and personal access tokens
diff --git a/config/routes.rb b/config/routes.rb
index 83c3a42c19f..659ea51bc75 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -88,4 +88,6 @@ Rails.application.routes.draw do
get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: /.*/ }
root to: "root#index"
+
+ get '*unmatched_route', to: 'application#not_found'
end
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index e4d996a3fb6..9b74364849e 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -113,17 +113,18 @@ module ExtractsPath
@id = get_id
@ref, @path = extract_ref(@id)
@repo = @project.repository
- if @options[:extended_sha1].blank?
- @commit = @repo.commit(@ref)
- else
- @commit = @repo.commit(@options[:extended_sha1])
- end
- if @path.empty? && !@commit
- @id = @ref = extract_ref_without_atom(@id)
+ if @options[:extended_sha1].present?
+ @commit = @repo.commit(@options[:extended_sha1])
+ else
@commit = @repo.commit(@ref)
- request.format = :atom if @commit
+ if @path.empty? && !@commit && @id.ends_with?('.atom')
+ @id = @ref = extract_ref_without_atom(@id)
+ @commit = @repo.commit(@ref)
+
+ request.format = :atom if @commit
+ end
end
raise InvalidPathError unless @commit
diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb
index 5a1ed7d4a25..27f0fd22ae6 100644
--- a/spec/requests/git_http_spec.rb
+++ b/spec/requests/git_http_spec.rb
@@ -412,9 +412,10 @@ describe 'Git HTTP requests', lib: true do
context "when the params are anything else" do
let(:params) { { service: 'git-implode-pack' } }
+ before { get path, params }
- it "fails to find a route" do
- expect { get(path, params) }.to raise_error(ActionController::RoutingError)
+ it "redirects to the sign-in page" do
+ expect(response).to redirect_to(new_user_session_path)
end
end
end