FIX: if people link own post, watchers not notified
This commit is contained in:
parent
f0694d491a
commit
cba76db53b
|
@ -283,7 +283,7 @@ class PostAlerter
|
|||
if !linked_post && topic = link.link_topic
|
||||
linked_post = topic.posts(post_number: 1).first
|
||||
end
|
||||
linked_post && post.user_id != linked_post.user_id && linked_post.user
|
||||
(linked_post && post.user_id != linked_post.user_id && linked_post.user) || nil
|
||||
end.compact
|
||||
end
|
||||
|
||||
|
|
|
@ -80,11 +80,18 @@ describe PostAlerter do
|
|||
|
||||
expect(user.notifications.count).to eq(1)
|
||||
|
||||
create_post(user: user, raw: "my magic topic\n##{Discourse.base_url}#{post1.url}")
|
||||
topic = Fabricate(:topic)
|
||||
|
||||
watcher = Fabricate(:user)
|
||||
TopicUser.create!(user_id: watcher.id, topic_id: topic.id, notification_level: TopicUser.notification_levels[:watching])
|
||||
|
||||
create_post(topic_id: topic.id, user: user, raw: "my magic topic\n##{Discourse.base_url}#{post1.url}")
|
||||
|
||||
user.reload
|
||||
expect(user.notifications.count).to eq(1)
|
||||
|
||||
expect(watcher.notifications.count).to eq(1)
|
||||
|
||||
# don't notify on reflection
|
||||
post1.reload
|
||||
expect(PostAlerter.new.extract_linked_users(post1).length).to eq(0)
|
||||
|
|
Loading…
Reference in New Issue