From f62f0c258d89465bea514e5127ea1effdeb3b35d Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Thu, 18 May 2017 20:08:32 +0000 Subject: Fixes for the rename reserved paths helpers --- .../v1/rename_namespaces_spec.rb | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb') 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 ec444942804..c56fded7516 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 @@ -137,7 +137,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do end describe "#rename_namespace" do - let(:namespace) { create(:namespace, path: 'the-path') } + let(:namespace) { create(:group, name: 'the-path') } it 'renames paths & routes for the namespace' do expect(subject).to receive(:rename_path_for_routable). @@ -177,6 +177,31 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do subject.rename_namespace(namespace) end + + it "doesn't rename users for other namespaces" do + expect(subject).not_to receive(:rename_user) + + subject.rename_namespace(namespace) + end + + it 'renames the username of a namespace for a user' do + user = create(:user, username: 'the-path') + + expect(subject).to receive(:rename_user).with('the-path', 'the-path0') + + subject.rename_namespace(user.namespace) + end + end + + describe '#rename_user' do + it 'renames a username' do + subject = described_class.new([], migration) + user = create(:user, username: 'broken') + + subject.rename_user('broken', 'broken0') + + expect(user.reload.username).to eq('broken0') + end end describe '#rename_namespaces' do -- cgit v1.2.3