Fix receiving multiple mentioned-in-comment notifications
When somebody commented multiple times and is mentioned in another comment afterwards, the person received multiple notifications.
This commit is contained in:
parent
eac8c7572c
commit
3d95642aca
2 changed files with 13 additions and 1 deletions
|
|
@ -11,7 +11,7 @@ module Notifications
|
|||
end
|
||||
|
||||
def self.filter_mentions(mentions, mentionable, _recipient_user_ids)
|
||||
mentions.joins(:person).merge(Person.allowed_to_be_mentioned_in_a_comment_to(mentionable.parent))
|
||||
mentions.includes(:person).merge(Person.allowed_to_be_mentioned_in_a_comment_to(mentionable.parent)).distinct
|
||||
end
|
||||
|
||||
def mail_job
|
||||
|
|
|
|||
|
|
@ -376,6 +376,18 @@ describe "mentioning", type: :request do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "only creates one notification for the mentioned person, when mentioned person commented twice before" do
|
||||
parent = FactoryGirl.create(:status_message_in_aspect, author: author.person)
|
||||
mentioned_user = FactoryGirl.create(:user_with_aspect, friends: [author])
|
||||
mentioned_user.comment!(parent, "test comment 1")
|
||||
mentioned_user.comment!(parent, "test comment 2")
|
||||
comment = inlined_jobs do
|
||||
author.comment!(parent, text_mentioning(mentioned_user))
|
||||
end
|
||||
|
||||
expect(notifications_about_mentioning(mentioned_user, comment).count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue