Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def downcase_diaspora_handle
# @param [Post] the post for which we query mentionable in comments people
# @return [Person::ActiveRecord_Relation]
scope :allowed_to_be_mentioned_in_a_comment_to, ->(post) {
allowed = if post.public?
allowed = if post.nil?
none
elsif post.public?
all
else
left_join_visible_post_interactions_on_authorship(post.id)
Expand Down
11 changes: 11 additions & 0 deletions spec/models/notifications/mentioned_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,16 @@ def self.filter_mentions(mentions, *)
expect(TestNotification).not_to receive(:create_notification)
TestNotification.notify(status_message, nil)
end

it "doesn't create a notification for a mention in a comment of an already deleted post" do
post = FactoryGirl.create(:status_message, public: true)
comment = FactoryGirl.create(:comment, commentable: post, text: text_mentioning(alice))
post.delete
comment.reload

expect {
Notifications::MentionedInComment.notify(comment, [alice])
}.to_not change(Notification, :count)
end
end
end