summaryrefslogtreecommitdiff
path: root/spec/services/groups/update_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/groups/update_service_spec.rb')
-rw-r--r--spec/services/groups/update_service_spec.rb40
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