PERF: Only log the first skipped email when user exceeds daily limit.

https://meta.discourse.org/t/cleaning-up-e-mail-logs/39132
This commit is contained in:
Guo Xiang Tan
2018-08-08 16:25:00 +08:00
parent 1ea23b1eae
commit ba6f11c521
2 changed files with 21 additions and 4 deletions

View File

@@ -126,8 +126,15 @@ describe Jobs::NotifyMailingListSubscribers do
mailing_list_user.email_logs.create(email_type: 'foobar', to_address: mailing_list_user.email)
}
Jobs::NotifyMailingListSubscribers.new.execute(post_id: post.id)
UserNotifications.expects(:mailing_list_notify).with(mailing_list_user, post).never
expect do
UserNotifications.expects(:mailing_list_notify)
.with(mailing_list_user, post)
.never
2.times do
Jobs::NotifyMailingListSubscribers.new.execute(post_id: post.id)
end
end.to change { SkippedEmailLog.count }.by(1)
expect(SkippedEmailLog.exists?(
email_type: "mailing_list",