From 69cb5fba59a86af0e3311c3ff3e00d0c391797f0 Mon Sep 17 00:00:00 2001 From: Francesco Levorato Date: Thu, 17 Sep 2015 15:44:59 +0200 Subject: [PATCH] Make Project#find_with_namespace case-insensitive --- app/models/project.rb | 4 ++-- spec/models/project_spec.rb | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 6e2f9645661..3b233f2b890 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -235,10 +235,10 @@ class Project < ActiveRecord::Base return nil unless id.include?('/') id = id.split('/') - namespace = Namespace.find_by(path: id.first) + namespace = Namespace.by_path(id.first) return nil unless namespace - where(namespace_id: namespace.id).find_by(path: id.second) + where(namespace_id: namespace.id).where("LOWER(projects.path) = :path", path: id.second.downcase).first end def visibility_levels diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 2fcbd5ae108..5aaa3af4d20 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -220,6 +220,7 @@ describe Project do end it { expect(Project.find_with_namespace('gitlab/gitlabhq')).to eq(@project) } + it { expect(Project.find_with_namespace('GitLab/GitlabHQ')).to eq(@project) } it { expect(Project.find_with_namespace('gitlab-ci')).to be_nil } end end