Merge branch 'bvl-fix-dynamic-path-query' into 'master'
Only rename namespaces and projects with an invalid path See merge request !11338
This commit is contained in:
commit
4024200314
2 changed files with 32 additions and 1 deletions
|
@ -15,7 +15,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def path_patterns
|
def path_patterns
|
||||||
@path_patterns ||= paths.map { |path| "%#{path}" }
|
@path_patterns ||= paths.flat_map { |path| ["%/#{path}", path] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def rename_path_for_routable(routable)
|
def rename_path_for_routable(routable)
|
||||||
|
|
|
@ -23,6 +23,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
|
||||||
|
|
||||||
found_ids = subject.namespaces_for_paths(type: :child).
|
found_ids = subject.namespaces_for_paths(type: :child).
|
||||||
map(&:id)
|
map(&:id)
|
||||||
|
|
||||||
expect(found_ids).to contain_exactly(child.id)
|
expect(found_ids).to contain_exactly(child.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -39,6 +40,22 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
|
||||||
|
|
||||||
found_ids = subject.namespaces_for_paths(type: :child).
|
found_ids = subject.namespaces_for_paths(type: :child).
|
||||||
map(&:id)
|
map(&:id)
|
||||||
|
|
||||||
|
expect(found_ids).to contain_exactly(namespace.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has no namespaces that look the same' do
|
||||||
|
_root_namespace = create(:namespace, path: 'THE-path')
|
||||||
|
_similar_path = create(:namespace,
|
||||||
|
path: 'not-really-the-path',
|
||||||
|
parent: create(:namespace))
|
||||||
|
namespace = create(:namespace,
|
||||||
|
path: 'the-path',
|
||||||
|
parent: create(:namespace))
|
||||||
|
|
||||||
|
found_ids = subject.namespaces_for_paths(type: :child).
|
||||||
|
map(&:id)
|
||||||
|
|
||||||
expect(found_ids).to contain_exactly(namespace.id)
|
expect(found_ids).to contain_exactly(namespace.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -53,6 +70,20 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
|
||||||
|
|
||||||
found_ids = subject.namespaces_for_paths(type: :top_level).
|
found_ids = subject.namespaces_for_paths(type: :top_level).
|
||||||
map(&:id)
|
map(&:id)
|
||||||
|
|
||||||
|
expect(found_ids).to contain_exactly(root_namespace.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has no namespaces that just look the same' do
|
||||||
|
root_namespace = create(:namespace, path: 'the-path')
|
||||||
|
_similar_path = create(:namespace, path: 'not-really-the-path')
|
||||||
|
_child_namespace = create(:namespace,
|
||||||
|
path: 'the-path',
|
||||||
|
parent: create(:namespace))
|
||||||
|
|
||||||
|
found_ids = subject.namespaces_for_paths(type: :top_level).
|
||||||
|
map(&:id)
|
||||||
|
|
||||||
expect(found_ids).to contain_exactly(root_namespace.id)
|
expect(found_ids).to contain_exactly(root_namespace.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue