This commit is contained in:
Guo Xiang Tan 2018-08-21 10:04:35 +08:00
parent 2d96160192
commit 2c70d3f443
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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