2016-02-09 01:47:35 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Jobs::CleanUpEmailLogs do
|
|
|
|
|
|
|
|
before 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)
|
2018-07-24 12:55:43 +08:00
|
|
|
|
|
|
|
Fabricate(:skipped_email_log, created_at: 2.years.ago)
|
|
|
|
Fabricate(:skipped_email_log)
|
2016-02-09 01:47:35 +08:00
|
|
|
end
|
|
|
|
|
2018-07-27 12:32:07 +08:00
|
|
|
it "removes old email logs" do
|
2016-02-09 01:47:35 +08:00
|
|
|
Jobs::CleanUpEmailLogs.new.execute({})
|
2018-07-18 16:28:44 +08:00
|
|
|
expect(EmailLog.count).to eq(2)
|
2018-07-24 12:55:43 +08:00
|
|
|
expect(SkippedEmailLog.count).to eq(1)
|
2016-02-09 01:47:35 +08:00
|
|
|
end
|
|
|
|
|
2016-02-09 05:18:52 +08:00
|
|
|
it "does not remove old email logs when delete_email_logs_after_days is 0" do
|
|
|
|
SiteSetting.delete_email_logs_after_days = 0
|
2016-02-09 01:47:35 +08:00
|
|
|
Jobs::CleanUpEmailLogs.new.execute({})
|
2018-07-18 16:28:44 +08:00
|
|
|
expect(EmailLog.count).to eq(3)
|
2018-07-24 12:55:43 +08:00
|
|
|
expect(SkippedEmailLog.count).to eq(2)
|
2016-02-09 01:47:35 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|