BUGFIX: don't alery myself when I link to myself
This commit is contained in:
parent
5bc8e7c19b
commit
9fc31932cf
|
@ -143,11 +143,11 @@ class PostAlerter
|
|||
|
||||
def extract_linked_users(post)
|
||||
post.topic_links.map do |link|
|
||||
post = link.link_post
|
||||
if !post && topic = link.link_topic
|
||||
post = topic.posts(post_number: 1).first
|
||||
linked_post = link.link_post
|
||||
if !linked_post && topic = link.link_topic
|
||||
linked_post = topic.posts(post_number: 1).first
|
||||
end
|
||||
post && post.user
|
||||
linked_post && post.user_id != linked_post.user_id && linked_post.user
|
||||
end.compact
|
||||
end
|
||||
|
||||
|
|
|
@ -6,10 +6,7 @@ describe PostAlerter do
|
|||
|
||||
def create_post_with_alerts(args={})
|
||||
post = Fabricate(:post, args)
|
||||
alerter = PostAlerter.new
|
||||
alerter.after_create_post(post)
|
||||
alerter.after_save_post(post)
|
||||
post
|
||||
PostAlerter.post_created(post)
|
||||
end
|
||||
|
||||
context 'quotes' do
|
||||
|
@ -35,6 +32,21 @@ describe PostAlerter do
|
|||
end
|
||||
end
|
||||
|
||||
context 'linked' do
|
||||
it "will notify correctly on linking" do
|
||||
post1 = create_post
|
||||
user = post1.user
|
||||
create_post(raw: "my magic topic\n##{Discourse.base_url}#{post1.url}")
|
||||
|
||||
user.notifications.count.should == 1
|
||||
|
||||
create_post(user: user, raw: "my magic topic\n##{Discourse.base_url}#{post1.url}")
|
||||
|
||||
user.reload
|
||||
user.notifications.count.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
context '@mentions' do
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
Loading…
Reference in New Issue