DEV: Improve `Jobs::CleanUpEmailLogs` specs.
This commit is contained in:
parent
26956bbe1a
commit
1b1ef21481
|
@ -1,27 +1,32 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Jobs::CleanUpEmailLogs do
|
describe Jobs::CleanUpEmailLogs do
|
||||||
|
let!(:email_log) { Fabricate(:email_log, created_at: 2.years.ago) }
|
||||||
|
let!(:email_log2) { Fabricate(:email_log, created_at: 2.weeks.ago) }
|
||||||
|
let!(:email_log3) { Fabricate(:email_log, created_at: 2.days.ago) }
|
||||||
|
|
||||||
before do
|
let!(:skipped_email_log) do
|
||||||
Fabricate(:email_log, created_at: 2.years.ago)
|
|
||||||
Fabricate(:email_log, created_at: 2.weeks.ago)
|
|
||||||
Fabricate(:email_log, created_at: 2.days.ago)
|
|
||||||
|
|
||||||
Fabricate(:skipped_email_log, created_at: 2.years.ago)
|
Fabricate(:skipped_email_log, created_at: 2.years.ago)
|
||||||
Fabricate(:skipped_email_log)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let!(:skipped_email_log2) { Fabricate(:skipped_email_log) }
|
||||||
|
|
||||||
it "removes old email logs" do
|
it "removes old email logs" do
|
||||||
Jobs::CleanUpEmailLogs.new.execute({})
|
Jobs::CleanUpEmailLogs.new.execute({})
|
||||||
expect(EmailLog.count).to eq(2)
|
expect(EmailLog.all).to contain_exactly(email_log2, email_log3)
|
||||||
expect(SkippedEmailLog.count).to eq(1)
|
expect(SkippedEmailLog.all).to contain_exactly(skipped_email_log2)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not remove old email logs when delete_email_logs_after_days is 0" do
|
it "does not remove old email logs when delete_email_logs_after_days is 0" do
|
||||||
SiteSetting.delete_email_logs_after_days = 0
|
SiteSetting.delete_email_logs_after_days = 0
|
||||||
Jobs::CleanUpEmailLogs.new.execute({})
|
Jobs::CleanUpEmailLogs.new.execute({})
|
||||||
expect(EmailLog.count).to eq(3)
|
|
||||||
expect(SkippedEmailLog.count).to eq(2)
|
expect(EmailLog.all).to contain_exactly(email_log, email_log2, email_log3)
|
||||||
|
|
||||||
|
expect(SkippedEmailLog.all).to contain_exactly(
|
||||||
|
skipped_email_log,
|
||||||
|
skipped_email_log2
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue