Don't notify yourself of self-assignments

This commit is contained in:
Jorge Manrubia
2025-05-01 12:57:25 +02:00
parent cb4c163d62
commit 0045e48f70
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ class Notifier::CardEventNotifier < Notifier
def recipients
case source.action
when "card_assigned"
source.assignees.excluding(source.collection.access_only_users)
source.assignees.excluding(creator, *source.collection.access_only_users)
when "card_published"
watchers_and_subscribers(include_only_watching: true).without(creator, *card.mentionees)
when "comment_created"
@@ -56,6 +56,15 @@ class Notifier::EventNotifierTest < ActiveSupport::TestCase
end
test "assignment events do not notify users who are access-only for the collection" do
collections(:writebook).access_for(users(:jz)).watching!
events(:logo_assignment_jz).update! creator: users(:jz)
notifications = Notifier.for(events(:logo_assignment_jz)).notify
assert_empty notifications
end
test "assignment events do not notify you if you assigned yourself" do
collections(:writebook).access_for(users(:jz)).access_only!
notifications = Notifier.for(events(:logo_assignment_jz)).notify