Fix: dismiss notifications from comments

This commit is contained in:
Jorge Manrubia
2025-04-25 19:52:09 +02:00
parent d96db67734
commit 5e279ab2e1
2 changed files with 20 additions and 2 deletions
+14 -2
View File
@@ -13,7 +13,19 @@ module Card::Readable
end
def notification_sources
events + mentions + comment_mentions
event_notification_sources + mention_notification_sources
end
def event_notification_sources
events + comment_creation_events
end
def mention_notification_sources
mentions + comment_mentions
end
def comment_creation_events
Event.where(eventable: comments)
end
def comment_mentions
@@ -21,6 +33,6 @@ module Card::Readable
end
def comments
Comment.where(id: messages.comments.pluck(:messageable_id))
@comments ||= Comment.where(id: messages.comments.pluck(:messageable_id))
end
end
+6
View File
@@ -20,4 +20,10 @@ class Card::ReadableTest < ActiveSupport::TestCase
cards(:logo).read_by(users(:david))
end
end
test "read clears notifications from the comments" do
assert_changes -> { notifications(:layout_commented_kevin).reload.read? }, from: false, to: true do
cards(:layout).read_by(users(:kevin))
end
end
end