summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2017-04-30 20:06:11 +0200
committerBob Van Landuyt <bob@gitlab.com>2017-05-01 11:14:24 +0200
commit2e2a63c8669a084ed3a3aa5e770158ea2cb43a9d (patch)
tree3dd6be25223a6fb48c0119a55b62efccade19680 /spec
parent08b1bc3489e8d4e6d5786221bad090f16a1c021f (diff)
downloadgitlab-ce-2e2a63c8669a084ed3a3aa5e770158ea2cb43a9d.tar.gz
Rename child namespaces in migrationhelpers
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb8
-rw-r--r--spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb (renamed from spec/lib/gitlab/database/rename_reserved_paths_migration_spec.rb)28
2 files changed, 22 insertions, 14 deletions
diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
index 6d58413edf2..a25c5da488a 100644
--- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
+++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
@@ -21,13 +21,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
parent = create(:namespace, path: 'parent')
child = create(:namespace, path: 'the-path', parent: parent)
- found_ids = subject.namespaces_for_paths(type: :wildcard).
+ found_ids = subject.namespaces_for_paths(type: :child).
map(&:id)
expect(found_ids).to contain_exactly(child.id)
end
end
- context 'for wildcard namespaces' do
+ context 'for child namespaces' do
it 'only returns child namespaces with the correct path' do
_root_namespace = create(:namespace, path: 'THE-path')
_other_path = create(:namespace,
@@ -37,7 +37,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
path: 'the-path',
parent: create(:namespace))
- found_ids = subject.namespaces_for_paths(type: :wildcard).
+ found_ids = subject.namespaces_for_paths(type: :child).
map(&:id)
expect(found_ids).to contain_exactly(namespace.id)
end
@@ -165,7 +165,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
expect(subject).to receive(:rename_namespace).
with(migration_namespace(child_namespace))
- subject.rename_namespaces(type: :wildcard)
+ subject.rename_namespaces(type: :child)
end
end
end
diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb
index 743054e0efc..f8cc1eb91ec 100644
--- a/spec/lib/gitlab/database/rename_reserved_paths_migration_spec.rb
+++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb
@@ -1,5 +1,18 @@
require 'spec_helper'
+shared_examples 'renames child namespaces' do |type|
+ it 'renames namespaces' do
+ rename_namespaces = double
+ expect(described_class::RenameNamespaces).
+ to receive(:new).with(['first-path', 'second-path'], subject).
+ and_return(rename_namespaces)
+ expect(rename_namespaces).to receive(:rename_namespaces).
+ with(type: :child)
+
+ subject.rename_wildcard_paths(['first-path', 'second-path'])
+ end
+end
+
describe Gitlab::Database::RenameReservedPathsMigration::V1 do
let(:subject) { FakeRenameReservedPathMigrationV1.new }
@@ -7,17 +20,12 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1 do
allow(subject).to receive(:say)
end
- describe '#rename_wildcard_paths' do
- it 'should rename namespaces' do
- rename_namespaces = double
- expect(described_class::RenameNamespaces).
- to receive(:new).with(['first-path', 'second-path'], subject).
- and_return(rename_namespaces)
- expect(rename_namespaces).to receive(:rename_namespaces).
- with(type: :wildcard)
+ describe '#rename_child_paths' do
+ it_behaves_like 'renames child namespaces'
+ end
- subject.rename_wildcard_paths(['first-path', 'second-path'])
- end
+ describe '#rename_wildcard_paths' do
+ it_behaves_like 'renames child namespaces'
it 'should rename projects' do
rename_projects = double