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