summaryrefslogtreecommitdiff
path: root/spec/services/groups/update_service_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/services/groups/update_service_spec.rb
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
downloadgitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/services/groups/update_service_spec.rb')
-rw-r--r--spec/services/groups/update_service_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb
index 25c79d9e600..1e6a8d53354 100644
--- a/spec/services/groups/update_service_spec.rb
+++ b/spec/services/groups/update_service_spec.rb
@@ -9,6 +9,50 @@ RSpec.describe Groups::UpdateService do
let!(:public_group) { create(:group, :public) }
describe "#execute" do
+ shared_examples 'with packages' do
+ before do
+ group.add_owner(user)
+ end
+
+ context 'with npm packages' do
+ let!(:package) { create(:npm_package, project: project) }
+
+ it 'does not allow a path update' do
+ expect(update_group(group, user, path: 'updated')).to be false
+ expect(group.errors[:path]).to include('cannot change when group contains projects with NPM packages')
+ end
+
+ it 'allows name update' do
+ expect(update_group(group, user, name: 'Updated')).to be true
+ expect(group.errors).to be_empty
+ expect(group.name).to eq('Updated')
+ end
+ end
+ end
+
+ context 'with project' do
+ let!(:group) { create(:group, :public) }
+ let(:project) { create(:project, namespace: group) }
+
+ it_behaves_like 'with packages'
+
+ context 'located in a subgroup' do
+ let(:subgroup) { create(:group, parent: group) }
+ let!(:project) { create(:project, namespace: subgroup) }
+
+ before do
+ subgroup.add_owner(user)
+ end
+
+ it_behaves_like 'with packages'
+
+ it 'does allow a path update if there is not a root namespace change' do
+ expect(update_group(subgroup, user, path: 'updated')).to be true
+ expect(subgroup.errors[:path]).to be_empty
+ end
+ end
+ end
+
context "project visibility_level validation" do
context "public group with public projects" do
let!(:service) { described_class.new(public_group, user, visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
@@ -238,4 +282,8 @@ RSpec.describe Groups::UpdateService do
end
end
end
+
+ def update_group(group, user, opts)
+ Groups::UpdateService.new(group, user, opts).execute
+ end
end