summaryrefslogtreecommitdiff
path: root/spec/services/notification_recipient_service_spec.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-06-28 11:44:32 +0100
committerSean McGivern <sean@gitlab.com>2017-06-28 12:14:44 +0100
commit60bd2ae372a9cab09990a6d2d5522ad3aeed8a40 (patch)
tree6720ff89f951c050458299b24af98efa95a8e2b3 /spec/services/notification_recipient_service_spec.rb
parent18a7fa550d2ab9ab4c20709a9fa0a0a75e3bf3c6 (diff)
downloadgitlab-ce-60bd2ae372a9cab09990a6d2d5522ad3aeed8a40.tar.gz
Ensure NotificationRecipientService doesn't modify participants
Even though it does modify the participants of the notification target in some cases, this should have been safe, as different workers are responsible for creating the notifications for each target. However, this is at best confusing, and we should ensure we don't do that.
Diffstat (limited to 'spec/services/notification_recipient_service_spec.rb')
-rw-r--r--spec/services/notification_recipient_service_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/services/notification_recipient_service_spec.rb b/spec/services/notification_recipient_service_spec.rb
new file mode 100644
index 00000000000..dfe1ee7c41e
--- /dev/null
+++ b/spec/services/notification_recipient_service_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe NotificationRecipientService, services: true do
+ set(:user) { create(:user) }
+ set(:project) { create(:empty_project, :public) }
+ set(:issue) { create(:issue, project: project) }
+
+ set(:watcher) do
+ watcher = create(:user)
+ setting = watcher.notification_settings_for(project)
+ setting.level = :watch
+ setting.save
+
+ watcher
+ end
+
+ subject { described_class.new(project) }
+
+ describe '#build_recipients' do
+ it 'does not modify the participants of the target' do
+ expect { subject.build_recipients(issue, user, action: :new_issue) }
+ .not_to change { issue.participants(user) }
+ end
+ end
+
+ describe '#build_new_note_recipients' do
+ set(:note) { create(:note_on_issue, noteable: issue, project: project) }
+
+ it 'does not modify the participants of the target' do
+ expect { subject.build_new_note_recipients(note) }
+ .not_to change { note.noteable.participants(note.author) }
+ end
+ end
+end