Revert renames from a migration

This commit is contained in:
Bob Van Landuyt 2017-06-12 11:03:28 +02:00 committed by Bob Van Landuyt
parent 152cba56e4
commit c98ed42d01
3 changed files with 28 additions and 0 deletions

View File

@ -104,5 +104,6 @@ class RenameAllReservedPathsAgain < ActiveRecord::Migration
end
def down
revert_renames
end
end

View File

@ -29,6 +29,11 @@ module Gitlab
paths = Array(paths)
RenameNamespaces.new(paths, self).rename_namespaces(type: :top_level)
end
def revert_renames
RenameProjects.new([], self).revert_renames
RenameNamespaces.new([], self).revert_renames
end
end
end
end

View File

@ -51,4 +51,26 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1, :truncate do
subject.rename_root_paths('the-path')
end
end
describe '#revert_renames' do
it 'renames namespaces' do
rename_namespaces = double
expect(described_class::RenameNamespaces).
to receive(:new).with([], subject).
and_return(rename_namespaces)
expect(rename_namespaces).to receive(:revert_renames)
subject.revert_renames
end
it 'renames projects' do
rename_projects = double
expect(described_class::RenameProjects).
to receive(:new).with([], subject).
and_return(rename_projects)
expect(rename_projects).to receive(:revert_renames)
subject.revert_renames
end
end
end