Commit 3e0b8e00 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Rename Routable.where_paths_in to Routable.where_full_path_in

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent d7010fdc
...@@ -29,17 +29,17 @@ module Routable ...@@ -29,17 +29,17 @@ module Routable
order_sql = "(CASE WHEN #{binary} routes.path = #{connection.quote(path)} THEN 0 ELSE 1 END)" order_sql = "(CASE WHEN #{binary} routes.path = #{connection.quote(path)} THEN 0 ELSE 1 END)"
where_paths_in([path]).reorder(order_sql).take where_full_path_in([path]).reorder(order_sql).take
end end
# Builds a relation to find multiple objects by their full paths. # Builds a relation to find multiple objects by their full paths.
# #
# Usage: # Usage:
# #
# Klass.where_paths_in(%w{gitlab-org/gitlab-ce gitlab-org/gitlab-ee}) # Klass.where_full_path_in(%w{gitlab-org/gitlab-ce gitlab-org/gitlab-ee})
# #
# Returns an ActiveRecord::Relation. # Returns an ActiveRecord::Relation.
def where_paths_in(paths) def where_full_path_in(paths)
wheres = [] wheres = []
cast_lower = Gitlab::Database.postgresql? cast_lower = Gitlab::Database.postgresql?
......
...@@ -248,7 +248,7 @@ module Banzai ...@@ -248,7 +248,7 @@ module Banzai
end end
def projects_relation_for_paths(paths) def projects_relation_for_paths(paths)
Project.where_paths_in(paths).includes(:namespace) Project.where_full_path_in(paths).includes(:namespace)
end end
# Returns projects for the given paths. # Returns projects for the given paths.
......
...@@ -39,16 +39,16 @@ describe Group, 'Routable' do ...@@ -39,16 +39,16 @@ describe Group, 'Routable' do
it { expect(described_class.find_by_full_path('unknown')).to eq(nil) } it { expect(described_class.find_by_full_path('unknown')).to eq(nil) }
end end
describe '.where_paths_in' do describe '.where_full_path_in' do
context 'without any paths' do context 'without any paths' do
it 'returns an empty relation' do it 'returns an empty relation' do
expect(described_class.where_paths_in([])).to eq([]) expect(described_class.where_full_path_in([])).to eq([])
end end
end end
context 'without any valid paths' do context 'without any valid paths' do
it 'returns an empty relation' do it 'returns an empty relation' do
expect(described_class.where_paths_in(%w[unknown])).to eq([]) expect(described_class.where_full_path_in(%w[unknown])).to eq([])
end end
end end
...@@ -56,13 +56,13 @@ describe Group, 'Routable' do ...@@ -56,13 +56,13 @@ describe Group, 'Routable' do
let!(:nested_group) { create(:group, parent: group) } let!(:nested_group) { create(:group, parent: group) }
it 'returns the projects matching the paths' do it 'returns the projects matching the paths' do
result = described_class.where_paths_in([group.to_param, nested_group.to_param]) result = described_class.where_full_path_in([group.to_param, nested_group.to_param])
expect(result).to contain_exactly(group, nested_group) expect(result).to contain_exactly(group, nested_group)
end end
it 'returns projects regardless of the casing of paths' do it 'returns projects regardless of the casing of paths' do
result = described_class.where_paths_in([group.to_param.upcase, nested_group.to_param.upcase]) result = described_class.where_full_path_in([group.to_param.upcase, nested_group.to_param.upcase])
expect(result).to contain_exactly(group, nested_group) expect(result).to contain_exactly(group, nested_group)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment