diff options
Diffstat (limited to 'spec/services/groups/update_service_spec.rb')
-rw-r--r-- | spec/services/groups/update_service_spec.rb | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb index ca8eaf4c970..1aa7e06182b 100644 --- a/spec/services/groups/update_service_spec.rb +++ b/spec/services/groups/update_service_spec.rb @@ -32,6 +32,43 @@ describe Groups::UpdateService do expect(service.execute).to be_falsey end + + context 'when a project has container images' do + let(:params) { { path: SecureRandom.hex } } + let!(:container_repository) { create(:container_repository, project: project) } + + subject { described_class.new(public_group, user, params).execute } + + context 'within group' do + let(:project) { create(:project, group: public_group) } + + context 'with path updates' do + it 'does not allow the update' do + expect(subject).to be false + expect(public_group.errors[:base].first).to match(/Docker images in their Container Registry/) + end + end + + context 'with name updates' do + let(:params) { { name: 'new-name' } } + + it 'allows the update' do + expect(subject).to be true + expect(public_group.reload.name).to eq('new-name') + end + end + end + + context 'within subgroup' do + let(:subgroup) { create(:group, parent: public_group) } + let(:project) { create(:project, group: subgroup) } + + it 'does not allow path updates' do + expect(subject).to be false + expect(public_group.errors[:base].first).to match(/Docker images in their Container Registry/) + end + end + end end context "internal group with internal project" do @@ -148,30 +185,6 @@ describe Groups::UpdateService do end end - context 'projects in group have container images' do - let(:service) { described_class.new(public_group, user, path: SecureRandom.hex) } - let(:project) { create(:project, :internal, group: public_group) } - - before do - stub_container_registry_tags(repository: /image/, tags: %w[rc1]) - create(:container_repository, project: project, name: :image) - end - - it 'does not allow path to be changed' do - result = described_class.new(public_group, user, path: 'new-path').execute - - expect(result).to eq false - expect(public_group.errors[:base].first).to match(/Docker images in their Container Registry/) - end - - it 'allows other settings to be changed' do - result = described_class.new(public_group, user, name: 'new-name').execute - - expect(result).to eq true - expect(public_group.reload.name).to eq('new-name') - end - end - context 'for a subgroup' do let(:subgroup) { create(:group, :private, parent: private_group) } |