Fix: dismiss notifications from comments
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user