diff options
author | Robert Speicher <robert@gitlab.com> | 2015-10-22 16:03:04 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2015-10-22 16:03:04 +0300 |
commit | 7924dd5c9f5d55daaa49132844e71d28169d0e20 (patch) | |
tree | 09b09ba4e2948662f4250714e4734aaaf9b20201 /spec/controllers | |
parent | b97977afef26e8aaad9228c8c7dffecdbe1a8e59 (diff) | |
parent | 98f982f91d6e2d6ec1b59ea5645d8320989e2de6 (diff) |
Merge branch 'project-path-case-sensitivity' into 'master'
Prefer project with exact path to differently cased one when both exist.
Fixes #3113.
See merge request !1649
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 4460bf12f96..4bb47c6b025 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -51,16 +51,39 @@ describe ProjectsController do end context "when requested with case sensitive namespace and project path" do - it "redirects to the normalized path for case mismatch" do - get :show, namespace_id: public_project.namespace.path, id: public_project.path.upcase + context "when there is a match with the same casing" do + it "loads the project" do + get :show, namespace_id: public_project.namespace.path, id: public_project.path - expect(response).to redirect_to("/#{public_project.path_with_namespace}") + expect(assigns(:project)).to eq(public_project) + expect(response.status).to eq(200) + end end - it "loads the page if normalized path matches request path" do - get :show, namespace_id: public_project.namespace.path, id: public_project.path + context "when there is a match with different casing" do + it "redirects to the normalized path" do + get :show, namespace_id: public_project.namespace.path, id: public_project.path.upcase + + expect(assigns(:project)).to eq(public_project) + expect(response).to redirect_to("/#{public_project.path_with_namespace}") + end + - expect(response.status).to eq(200) + # MySQL queries are case insensitive by default, so this spec would fail. + if Gitlab::Database.postgresql? + context "when there is also a match with the same casing" do + + let!(:other_project) { create(:project, :public, namespace: public_project.namespace, path: public_project.path.upcase) } + + it "loads the exactly matched project" do + + get :show, namespace_id: public_project.namespace.path, id: public_project.path.upcase + + expect(assigns(:project)).to eq(other_project) + expect(response.status).to eq(200) + end + end + end end end end |