diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/services/groups | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/services/groups')
-rw-r--r-- | spec/services/groups/import_export/import_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/groups/transfer_service_spec.rb | 71 |
2 files changed, 51 insertions, 22 deletions
diff --git a/spec/services/groups/import_export/import_service_spec.rb b/spec/services/groups/import_export/import_service_spec.rb index f8cb55a9955..0c7765dcd38 100644 --- a/spec/services/groups/import_export/import_service_spec.rb +++ b/spec/services/groups/import_export/import_service_spec.rb @@ -110,6 +110,7 @@ RSpec.describe Groups::ImportExport::ImportService do allow(Gitlab::Import::Logger).to receive(:build).and_return(import_logger) allow(import_logger).to receive(:error) allow(import_logger).to receive(:info) + allow(import_logger).to receive(:warn) allow(FileUtils).to receive(:rm_rf).and_call_original end @@ -220,6 +221,7 @@ RSpec.describe Groups::ImportExport::ImportService do allow(Gitlab::Import::Logger).to receive(:build).and_return(import_logger) allow(import_logger).to receive(:error) + allow(import_logger).to receive(:warn) allow(import_logger).to receive(:info) allow(FileUtils).to receive(:rm_rf).and_call_original end diff --git a/spec/services/groups/transfer_service_spec.rb b/spec/services/groups/transfer_service_spec.rb index ae04eca3a9f..19b746ade34 100644 --- a/spec/services/groups/transfer_service_spec.rb +++ b/spec/services/groups/transfer_service_spec.rb @@ -3,15 +3,15 @@ require 'spec_helper' RSpec.describe Groups::TransferService do - let(:user) { create(:user) } - let(:new_parent_group) { create(:group, :public) } + let_it_be(:user) { create(:user) } + let_it_be(:new_parent_group) { create(:group, :public) } let!(:group_member) { create(:group_member, :owner, group: group, user: user) } let(:transfer_service) { described_class.new(group, user) } context 'handling packages' do let_it_be(:group) { create(:group, :public) } + let_it_be(:new_group) { create(:group, :public) } let(:project) { create(:project, :public, namespace: group) } - let(:new_group) { create(:group, :public) } before do group.add_owner(user) @@ -35,8 +35,8 @@ RSpec.describe Groups::TransferService do it_behaves_like 'transfer not allowed' context 'with a project within subgroup' do - let(:root_group) { create(:group) } - let(:group) { create(:group, parent: root_group) } + let_it_be(:root_group) { create(:group) } + let_it_be(:group) { create(:group, parent: root_group) } before do root_group.add_owner(user) @@ -79,8 +79,6 @@ RSpec.describe Groups::TransferService do shared_examples 'ensuring allowed transfer for a group' do context "when there's an exception on GitLab shell directories" do - let(:new_parent_group) { create(:group, :public) } - before do allow_next_instance_of(described_class) do |instance| allow(instance).to receive(:update_group_attributes).and_raise(Gitlab::UpdatePathError, 'namespace directory cannot be moved') @@ -101,7 +99,7 @@ RSpec.describe Groups::TransferService do describe '#execute' do context 'when transforming a group into a root group' do - let!(:group) { create(:group, :public, :nested) } + let_it_be_with_reload(:group) { create(:group, :public, :nested) } it_behaves_like 'ensuring allowed transfer for a group' @@ -115,7 +113,7 @@ RSpec.describe Groups::TransferService do end context 'when the user does not have the right policies' do - let!(:group_member) { create(:group_member, :guest, group: group, user: user) } + let_it_be(:group_member) { create(:group_member, :guest, group: group, user: user) } it "returns false" do expect(transfer_service.execute(nil)).to be_falsy @@ -128,7 +126,7 @@ RSpec.describe Groups::TransferService do end context 'when there is a group with the same path' do - let!(:group) { create(:group, :public, :nested, path: 'not-unique') } + let_it_be(:group) { create(:group, :public, :nested, path: 'not-unique') } before do create(:group, path: 'not-unique') @@ -145,9 +143,9 @@ RSpec.describe Groups::TransferService do end context 'when the group is a subgroup and the transfer is valid' do - let!(:subgroup1) { create(:group, :private, parent: group) } - let!(:subgroup2) { create(:group, :internal, parent: group) } - let!(:project1) { create(:project, :repository, :private, namespace: group) } + let_it_be(:subgroup1) { create(:group, :private, parent: group) } + let_it_be(:subgroup2) { create(:group, :internal, parent: group) } + let_it_be(:project1) { create(:project, :repository, :private, namespace: group) } before do transfer_service.execute(nil) @@ -173,12 +171,12 @@ RSpec.describe Groups::TransferService do end context 'when transferring a subgroup into another group' do - let(:group) { create(:group, :public, :nested) } + let_it_be_with_reload(:group) { create(:group, :public, :nested) } it_behaves_like 'ensuring allowed transfer for a group' context 'when the new parent group is the same as the previous parent group' do - let(:group) { create(:group, :public, :nested, parent: new_parent_group) } + let_it_be(:group) { create(:group, :public, :nested, parent: new_parent_group) } it 'returns false' do expect(transfer_service.execute(new_parent_group)).to be_falsy @@ -191,7 +189,7 @@ RSpec.describe Groups::TransferService do end context 'when the user does not have the right policies' do - let!(:group_member) { create(:group_member, :guest, group: group, user: user) } + let_it_be(:group_member) { create(:group_member, :guest, group: group, user: user) } it "returns false" do expect(transfer_service.execute(new_parent_group)).to be_falsy @@ -221,7 +219,7 @@ RSpec.describe Groups::TransferService do end context 'when the parent group has a project with the same path' do - let!(:group) { create(:group, :public, :nested, path: 'foo') } + let_it_be_with_reload(:group) { create(:group, :public, :nested, path: 'foo') } before do create(:group_member, :owner, group: new_parent_group, user: user) @@ -240,8 +238,13 @@ RSpec.describe Groups::TransferService do end context 'when the group is allowed to be transferred' do + let_it_be(:new_parent_group_integration) { create(:slack_service, group: new_parent_group, project: nil, webhook: 'http://new-group.slack.com') } + before do + allow(PropagateIntegrationWorker).to receive(:perform_async) + create(:group_member, :owner, group: new_parent_group, user: user) + transfer_service.execute(new_parent_group) end @@ -267,6 +270,30 @@ RSpec.describe Groups::TransferService do end end + context 'with a group integration' do + let_it_be(:instance_integration) { create(:slack_service, :instance, webhook: 'http://project.slack.com') } + let(:new_created_integration) { Service.find_by(group: group) } + + context 'with an inherited integration' do + let_it_be(:group_integration) { create(:slack_service, group: group, project: nil, webhook: 'http://group.slack.com', inherit_from_id: instance_integration.id) } + + it 'replaces inherited integrations', :aggregate_failures do + expect(new_created_integration.webhook).to eq(new_parent_group_integration.webhook) + expect(PropagateIntegrationWorker).to have_received(:perform_async).with(new_created_integration.id) + expect(Service.count).to eq(3) + end + end + + context 'with a custom integration' do + let_it_be(:group_integration) { create(:slack_service, group: group, project: nil, webhook: 'http://group.slack.com') } + + it 'does not updates the integrations', :aggregate_failures do + expect { transfer_service.execute(new_parent_group) }.not_to change { group_integration.webhook } + expect(PropagateIntegrationWorker).not_to have_received(:perform_async) + end + end + end + it 'updates visibility for the group based on the parent group' do expect(group.visibility_level).to eq(new_parent_group.visibility_level) end @@ -464,7 +491,7 @@ RSpec.describe Groups::TransferService do end context 'updated paths' do - let(:group) { create(:group, :public) } + let_it_be_with_reload(:group) { create(:group, :public) } before do transfer_service.execute(new_parent_group) @@ -500,10 +527,10 @@ RSpec.describe Groups::TransferService do end context 'resets project authorizations' do - let(:old_parent_group) { create(:group) } - let(:group) { create(:group, :private, parent: old_parent_group) } - let(:new_group_member) { create(:user) } - let(:old_group_member) { create(:user) } + let_it_be(:old_parent_group) { create(:group) } + let_it_be_with_reload(:group) { create(:group, :private, parent: old_parent_group) } + let_it_be(:new_group_member) { create(:user) } + let_it_be(:old_group_member) { create(:user) } before do new_parent_group.add_maintainer(new_group_member) |