Skip to content
Snippets Groups Projects
Commit 69cb5fba authored by Francesco Levorato's avatar Francesco Levorato
Browse files

Make Project#find_with_namespace case-insensitive

parent ac571623
No related branches found
No related tags found
1 merge request!1330Add redirect from incorrectly cased group or project path to correct one
Loading
@@ -235,10 +235,10 @@ class Project < ActiveRecord::Base
Loading
@@ -235,10 +235,10 @@ class Project < ActiveRecord::Base
return nil unless id.include?('/') return nil unless id.include?('/')
   
id = id.split('/') id = id.split('/')
namespace = Namespace.find_by(path: id.first) namespace = Namespace.by_path(id.first)
return nil unless namespace 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 end
   
def visibility_levels def visibility_levels
Loading
Loading
Loading
@@ -220,6 +220,7 @@ describe Project do
Loading
@@ -220,6 +220,7 @@ describe Project do
end 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/GitlabHQ')).to eq(@project) }
it { expect(Project.find_with_namespace('gitlab-ci')).to be_nil } it { expect(Project.find_with_namespace('gitlab-ci')).to be_nil }
end end
end end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment