From c279889191570cf7d5cf4fe1920f3b10b32deba0 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 21 Jul 2016 15:05:10 -0400 Subject: [PATCH] FIX: Watching First Post in groups was working incorrectly --- app/services/post_alerter.rb | 2 +- spec/services/post_alerter_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb index 073c2ba06bd..86ecfbc2f1a 100644 --- a/app/services/post_alerter.rb +++ b/app/services/post_alerter.rb @@ -120,7 +120,7 @@ class PostAlerter .where(notification_level: TagUser.notification_levels[:watching_first_post]) .pluck(:user_id) - group_ids = post.user.groups.pluck(:id) + group_ids = topic.allowed_groups.pluck(:group_id) group_watchers = GroupUser.where(group_id: group_ids, notification_level: GroupUser.notification_levels[:watching_first_post]) .pluck(:user_id) diff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rb index 4f7e2009755..e0288c4a6ee 100644 --- a/spec/services/post_alerter_spec.rb +++ b/spec/services/post_alerter_spec.rb @@ -363,6 +363,7 @@ describe PostAlerter do it "notifies the user who is following the first post group" do GroupUser.create(group_id: group.id, user_id: user.id) GroupUser.create(group_id: group.id, user_id: post.user.id) + topic.topic_allowed_groups.create(group_id: group.id) level = GroupUser.notification_levels[:watching_first_post] GroupUser.where(user_id: user.id, group_id: group.id).update_all(notification_level: level)