Make Project#find_with_namespace case-insensitive

This commit is contained in:
Francesco Levorato 2015-09-17 15:44:59 +02:00
parent ac571623d8
commit 69cb5fba59
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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