FIX: Don't alert on new posts in a topic unless it's a new record

This commit is contained in:
Robin Ward 2016-07-19 15:57:05 -04:00
parent 8141e1d9bc
commit 09be741820
2 changed files with 9 additions and 2 deletions

View File

@ -108,7 +108,7 @@ class PostAlerter
sync_group_mentions(post, mentioned_groups)
if post.post_number == 1
if new_record && post.post_number == 1
topic = post.topic
if topic.present?

View File

@ -342,10 +342,17 @@ describe PostAlerter do
it "notifies the user who is following the first post category" do
level = CategoryUser.notification_levels[:watching_first_post]
CategoryUser.set_notification_level_for_category(user, level, category.id)
PostAlerter.post_created(post)
PostAlerter.new.after_save_post(post, true)
expect(user.notifications.where(notification_type: Notification.types[:watching_first_post]).count).to eq(1)
end
it "doesn't notify when the record is not new" do
level = CategoryUser.notification_levels[:watching_first_post]
CategoryUser.set_notification_level_for_category(user, level, category.id)
PostAlerter.new.after_save_post(post, false)
expect(user.notifications.where(notification_type: Notification.types[:watching_first_post]).count).to eq(0)
end
it "notifies the user who is following the first post tag" do
level = TagUser.notification_levels[:watching_first_post]
TagUser.change(user.id, tag.id, level)