summaryrefslogtreecommitdiff
path: root/spec/controllers/projects_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r--spec/controllers/projects_controller_spec.rb35
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