Skip to content
Snippets Groups Projects
Commit ae84e350 authored by Bob Van Landuyt :neckbeard:'s avatar Bob Van Landuyt :neckbeard: :sunglasses:
Browse files

Only rename exact matches for the route

The only path we need to rename is the exact match `old_path` and
child matches `old_path/%` instead of `old_path` wich would rename
routes that just look similar.
parent aa47d99b
No related branches found
No related tags found
1 merge request!11492Fixes for the rename reserved paths helpers
Pipeline #
Loading
Loading
@@ -41,7 +41,9 @@ module Gitlab
new_full_path)
 
update_column_in_batches(:routes, :path, replace_statement) do |table, query|
query.where(MigrationClasses::Route.arel_table[:path].matches("#{old_full_path}%"))
path_or_children = table[:path].eq(old_full_path)
.or(table[:path].matches("#{old_full_path}/%"))
query.where(path_or_children)
end
end
 
Loading
Loading
Loading
Loading
@@ -107,6 +107,15 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase do
expect(new_path).to eq('the-path0')
end
 
it "doesn't rename routes that start with a similar name" do
other_namespace = create(:namespace, path: 'the-path-but-not-really')
project = create(:empty_project, path: 'the-project', namespace: other_namespace)
subject.rename_path_for_routable(migration_namespace(namespace))
expect(project.route.reload.path).to eq('the-path-but-not-really/the-project')
end
context "the-path namespace -> subgroup -> the-path0 project" do
it "updates the route of the project correctly" do
subgroup = create(:group, path: "subgroup", parent: namespace)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment