diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-10-20 17:16:08 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-10-20 17:16:08 +0300 |
commit | 2f7fc7e9f7e7a43914abe81a510bd0dffa113979 (patch) | |
tree | 58a5e745f1d11d1ada904fc69193c2ef25de7279 /spec/controllers | |
parent | 97eafd4b3dbc186fc3d633c20a7e364ebf31849d (diff) |
Prefer project with exact path to differently cased one when both exist.
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 4460bf12f96..5090f87c73d 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -51,16 +51,34 @@ 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) + 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 |