mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 11:53:40 +08:00
4670b62969
Convert all IMAP logging to write to a database table for easier inspection. These logs are cleaned up daily if they are > 5 days old. Logs can easily be watched in dev by setting DISCOURSE_DEV_LOG_LEVEL=\"debug\" and running tail -f development.log | grep IMAP
21 lines
514 B
Ruby
21 lines
514 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe Jobs::CleanupImapSyncLog do
|
|
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)
|
|
|
|
log2.update(created_at: Time.now - 6.days)
|
|
log3.update(created_at: Time.now - 7.days)
|
|
|
|
job_class.execute({})
|
|
|
|
expect(ImapSyncLog.count).to eq(1)
|
|
end
|
|
end
|