From 2c70d3f443a5fc180dd05e4c5ff5fd8fa52931c0 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 21 Aug 2018 10:04:35 +0800 Subject: [PATCH] Take 2 on https://github.com/discourse/discourse/commit/ba6f11c521b66870a6cd2c39785aa0dbcdabcecf. --- app/jobs/regular/notify_mailing_list_subscribers.rb | 2 +- spec/jobs/notify_mailing_list_subscribers_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/jobs/regular/notify_mailing_list_subscribers.rb b/app/jobs/regular/notify_mailing_list_subscribers.rb index d6f0484cef1..811d75b6253 100644 --- a/app/jobs/regular/notify_mailing_list_subscribers.rb +++ b/app/jobs/regular/notify_mailing_list_subscribers.rb @@ -91,7 +91,7 @@ module Jobs if reason_type == SkippedEmailLog.reason_types[:exceeded_emails_limit] exists = SkippedEmailLog.exists?({ created_at: (Time.zone.now.beginning_of_day..Time.zone.now.end_of_day) - }.merge(attributes)) + }.merge!(attributes.except(:post_id))) return if exists end diff --git a/spec/jobs/notify_mailing_list_subscribers_spec.rb b/spec/jobs/notify_mailing_list_subscribers_spec.rb index 7bb5b3265f4..9af92d9e863 100644 --- a/spec/jobs/notify_mailing_list_subscribers_spec.rb +++ b/spec/jobs/notify_mailing_list_subscribers_spec.rb @@ -134,6 +134,10 @@ describe Jobs::NotifyMailingListSubscribers do 2.times do Jobs::NotifyMailingListSubscribers.new.execute(post_id: post.id) end + + Jobs::NotifyMailingListSubscribers.new.execute( + post_id: Fabricate(:post, user: user) + ) end.to change { SkippedEmailLog.count }.by(1) expect(SkippedEmailLog.exists?( @@ -143,6 +147,14 @@ describe Jobs::NotifyMailingListSubscribers do to_address: mailing_list_user.email, reason_type: SkippedEmailLog.reason_types[:exceeded_emails_limit] )).to eq(true) + + freeze_time(Time.zone.now + 1.day) + + expect do + Jobs::NotifyMailingListSubscribers.new.execute( + post_id: Fabricate(:post, user: user) + ) + end.to change { SkippedEmailLog.count }.by(1) end end