2020-08-14 10:01:31 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe Jobs::CleanupImapSyncLog do
|
2020-08-14 10:01:31 +08:00
|
|
|
let(:job_class) { Jobs::CleanupImapSyncLog.new }
|
|
|
|
|
|
|
|
it "deletes logs older than RETAIN_LOGS_DAYS" do
|
|
|
|
log1 = ImapSyncLog.log("Test log 1", :debug)
|
|
|
|
log2 = ImapSyncLog.log("Test log 2", :debug)
|
|
|
|
log3 = ImapSyncLog.log("Test log 3", :debug)
|
|
|
|
|
2020-09-10 11:41:46 +08:00
|
|
|
log2.update(created_at: 6.days.ago)
|
|
|
|
log3.update(created_at: 7.days.ago)
|
2020-08-14 10:01:31 +08:00
|
|
|
|
|
|
|
job_class.execute({})
|
|
|
|
|
|
|
|
expect(ImapSyncLog.count).to eq(1)
|
|
|
|
end
|
2021-01-21 09:37:47 +08:00
|
|
|
|
|
|
|
it "does not write the log to the db if specified" do
|
|
|
|
ImapSyncLog.debug("test", Fabricate(:group), db: false)
|
|
|
|
expect(ImapSyncLog.count).to eq(0)
|
|
|
|
end
|
2020-08-14 10:01:31 +08:00
|
|
|
end
|