do not notify staged users about posts withing mailinglist mirror category

This commit is contained in:
Gerhard Schlager 2017-11-17 14:50:35 +01:00
parent 1a3ab7c02e
commit d47fa6653b
2 changed files with 17 additions and 0 deletions

View File

@ -298,6 +298,8 @@ class PostAlerter
# Make sure the user can see the post
return unless Guardian.new(user).can_see?(post)
return if user.staged? && post.topic.category&.mailinglist_mirror?
notifier_id = opts[:user_id] || post.user_id # xxxxx look at revision history
# apply muting here

View File

@ -627,6 +627,21 @@ describe PostAlerter do
expect(dave.notifications.count).to eq(1)
expect(erin.notifications.count).to eq(1)
end
it "does not send email notifications to staged users when notification originates in mailinglist mirror category" do
category = Fabricate(:mailinglist_mirror_category)
topic = Fabricate(:topic, category: category)
user = Fabricate(:staged)
post = Fabricate(:post, user: user, topic: topic)
reply = Fabricate(:post, topic: topic, reply_to_post_number: 1)
NotificationEmailer.expects(:process_notification).never
expect { PostAlerter.post_created(reply) }.to change(user.notifications, :count).by(0)
category.mailinglist_mirror = false
NotificationEmailer.expects(:process_notification).once
expect { PostAlerter.post_created(reply) }.to change(user.notifications, :count).by(1)
end
end
context "watching" do