A platform for community discussion. Free, open, simple.
FIX: Ensure reviewable counts are updated correctly for new user menu (#21222)
David Taylorcd88af88767e
diff --git a/app/jobs/regular/notify_reviewable.rb b/app/jobs/regular/notify_reviewable.rbindex 7546030c999..ed02886b615 100644--- a/app/jobs/regular/notify_reviewable.rb+++ b/app/jobs/regular/notify_reviewable.rb@@ -35,7 +35,7 @@ class Jobs::NotifyReviewable < ::Jobs::Basecounts[reviewable_by_group_id] += count if reviewable_by_group_idend- if SiteSetting.legacy_navigation_menu?+ if legacy_user_menu?notify_legacy(User.real.admins.pluck(:id),count: counts[:admins],@@ -46,7 +46,7 @@ class Jobs::NotifyReviewable < ::Jobs::Baseendif reviewable.reviewable_by_moderator?- if SiteSetting.legacy_navigation_menu?+ if legacy_user_menu?notify_legacy(User.real.moderators.where("id NOT IN (?)", @contacted).pluck(:id),count: counts[:moderators],@@ -71,7 +71,7 @@ class Jobs::NotifyReviewable < ::Jobs::Basecount += counts[gu.group_id]end- if SiteSetting.legacy_navigation_menu?+ if legacy_user_menu?notify_legacy([user.id], count: count, updates: updates)elsenotify_user(user, updates)@@ -103,4 +103,8 @@ class Jobs::NotifyReviewable < ::Jobs::Basedef notify_user(user, updates)user.publish_reviewable_counts(updates.present? ? { updates: updates } : nil)end++ def legacy_user_menu?+ SiteSetting.legacy_navigation_menu? && !SiteSetting.enable_new_notifications_menu+ endenddiff --git a/spec/jobs/notify_reviewable_spec.rb b/spec/jobs/notify_reviewable_spec.rbindex 4eecaf75e13..ecce49793fb 100644--- a/spec/jobs/notify_reviewable_spec.rb+++ b/spec/jobs/notify_reviewable_spec.rb@@ -85,6 +85,7 @@ RSpec.describe Jobs::NotifyReviewable doit "will notify users of new reviewable content for the old user menu" doSiteSetting.navigation_menu = "legacy"+ SiteSetting.enable_new_notifications_menu = falseSiteSetting.enable_category_group_moderation = trueGroupUser.create!(group_id: group.id, user_id: moderator.id)@@ -170,6 +171,7 @@ RSpec.describe Jobs::NotifyReviewable doit "respects priority" doSiteSetting.navigation_menu = "legacy"+ SiteSetting.enable_new_notifications_menu = falseSiteSetting.enable_category_group_moderation = trueReviewable.set_priorities(medium: 2.0)SiteSetting.reviewable_default_visibility = "medium"@@ -224,6 +226,8 @@ RSpec.describe Jobs::NotifyReviewable doendit "skips sending notifications if user_ids is empty" do+ SiteSetting.navigation_menu = "legacy"+ SiteSetting.enable_new_notifications_menu = falsereviewable = Fabricate(:reviewable, reviewable_by_moderator: true)regular_user = Fabricate(:user)