From 79dc0518c944d3482c23289db8e799cd01302be7 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 23 Nov 2016 11:24:06 -0500 Subject: [PATCH] FIX: popular posts in digest need to use same restrictions as topics --- app/mailers/user_notifications.rb | 4 ++-- spec/mailers/user_notifications_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index d1d117995fc..9c845d78839 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -111,8 +111,8 @@ class UserNotifications < ActionMailer::Base @other_new_for_you = topics_for_digest.size > SiteSetting.digest_topics ? topics_for_digest[SiteSetting.digest_topics..-1] : [] @popular_posts = if SiteSetting.digest_posts > 0 - Post.public_posts - .where("posts.post_number > ? AND posts.score > ? AND posts.created_at > ?", 1, 5.0, min_date) + Post.for_mailing_list(user, min_date) + .where("posts.post_number > ? AND posts.score > ?", 1, 5.0) .order("posts.score DESC") .limit(SiteSetting.digest_posts) else diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb index 7d98425ce30..51f73a58ae2 100644 --- a/spec/mailers/user_notifications_spec.rb +++ b/spec/mailers/user_notifications_spec.rb @@ -155,8 +155,8 @@ describe UserNotifications do context "with new topics" do before do - Topic.expects(:for_digest).returns([Fabricate(:topic, user: Fabricate(:coding_horror))]) - Topic.expects(:new_since_last_seen).returns(Topic.none) + Topic.stubs(:for_digest).returns([Fabricate(:topic, user: Fabricate(:coding_horror))]) + Topic.stubs(:new_since_last_seen).returns(Topic.none) end it "works" do