diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /spec/services/groups/update_service_spec.rb | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'spec/services/groups/update_service_spec.rb')
-rw-r--r-- | spec/services/groups/update_service_spec.rb | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb index 856dd4a2567..5c87b9ac8bb 100644 --- a/spec/services/groups/update_service_spec.rb +++ b/spec/services/groups/update_service_spec.rb @@ -339,8 +339,44 @@ RSpec.describe Groups::UpdateService do end end + context 'EventStore' do + let(:service) { described_class.new(group, user, **params) } + let(:root_group) { create(:group, path: 'root') } + let(:group) do + create(:group, parent: root_group, path: 'old-path').tap { |g| g.add_owner(user) } + end + + context 'when changing a group path' do + let(:new_path) { SecureRandom.hex } + let(:params) { { path: new_path } } + + it 'publishes a GroupPathChangedEvent' do + old_path = group.full_path + + expect { service.execute } + .to publish_event(Groups::GroupPathChangedEvent) + .with( + group_id: group.id, + root_namespace_id: group.root_ancestor.id, + old_path: old_path, + new_path: "root/#{new_path}" + ) + end + end + + context 'when not changing a group path' do + let(:params) { { name: 'very-new-name' } } + + it 'does not publish a GroupPathChangedEvent' do + expect { service.execute } + .not_to publish_event(Groups::GroupPathChangedEvent) + end + end + end + context 'rename group' do - let!(:service) { described_class.new(internal_group, user, path: SecureRandom.hex) } + let(:new_path) { SecureRandom.hex } + let!(:service) { described_class.new(internal_group, user, path: new_path) } before do internal_group.add_member(user, Gitlab::Access::MAINTAINER) @@ -371,7 +407,7 @@ RSpec.describe Groups::UpdateService do end it "hasn't changed the path" do - expect { service.execute}.not_to change { internal_group.reload.path} + expect { service.execute }.not_to change { internal_group.reload.path } end end end |