discourse/spec/jobs/cleanup_imap_sync_log_spec.rb
Martin Brennan f34fa999a2
DEV: IMAP debugging improvements (#11784)
Improvements to make console access to IncomingEmail more pleasant, and stopping certain IMAP logs from landing in the DB because they just create too much noise,
2021-01-21 11:37:47 +10:00

26 lines
662 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: 6.days.ago)
log3.update(created_at: 7.days.ago)
job_class.execute({})
expect(ImapSyncLog.count).to eq(1)
end
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
end