summaryrefslogtreecommitdiff
path: root/spec/models/namespace_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/namespace_spec.rb')
-rw-r--r--spec/models/namespace_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index c1b385aaf76..9b7f932ec3a 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -205,6 +205,34 @@ describe Namespace do
expect(gitlab_shell.exists?(project.repository_storage, "#{namespace.path}/#{project.path}.git")).to be_truthy
end
+ context 'when #write_projects_repository_config raises an error' do
+ context 'in test environment' do
+ it 'raises an exception' do
+ expect(namespace).to receive(:write_projects_repository_config).and_raise('foo')
+
+ expect do
+ namespace.update(path: namespace.full_path + '_new')
+ end.to raise_error('foo')
+ end
+ end
+
+ context 'in production environment' do
+ it 'does not cancel later callbacks' do
+ expect(namespace).to receive(:write_projects_repository_config).and_raise('foo')
+ expect(namespace).to receive(:move_dir).and_wrap_original do |m, *args|
+ move_dir_result = m.call(*args)
+
+ expect(move_dir_result).to be_truthy # Must be truthy, or else later callbacks would be canceled
+
+ move_dir_result
+ end
+ expect(Gitlab::Sentry).to receive(:should_raise?).and_return(false) # like prod
+
+ namespace.update(path: namespace.full_path + '_new')
+ end
+ end
+ end
+
context 'with subgroups', :nested_groups do
let(:parent) { create(:group, name: 'parent', path: 'parent') }
let(:new_parent) { create(:group, name: 'new_parent', path: 'new_parent') }
@@ -295,6 +323,16 @@ describe Namespace do
parent.update(path: 'mygroup_new')
+ # Routes are loaded when creating the projects, so we need to manually
+ # reload them for the below code to be aware of the above UPDATE.
+ [
+ project_in_parent_group,
+ hashed_project_in_subgroup,
+ legacy_project_in_subgroup
+ ].each do |project|
+ project.route.reload
+ end
+
expect(project_rugged(project_in_parent_group).config['gitlab.fullpath']).to eq "mygroup_new/#{project_in_parent_group.path}"
expect(project_rugged(hashed_project_in_subgroup).config['gitlab.fullpath']).to eq "mygroup_new/mysubgroup/#{hashed_project_in_subgroup.path}"
expect(project_rugged(legacy_project_in_subgroup).config['gitlab.fullpath']).to eq "mygroup_new/mysubgroup/#{legacy_project_in_subgroup.path}"