discourse/spec/jobs/clean_up_email_logs_spec.rb
Sam Saffron 4ea21fa2d0 DEV: use #frozen_string_literal: true on all spec
This change both speeds up specs (less strings to allocate) and helps catch
cases where methods in Discourse are mutating inputs.

Overall we will be migrating everything to use #frozen_string_literal: true
it will take a while, but this is the first and safest move in this direction
2019-04-30 10:27:42 +10:00

35 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
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) }
let!(:skipped_email_log) do
Fabricate(:skipped_email_log, created_at: 2.years.ago)
end
let!(:skipped_email_log2) { Fabricate(:skipped_email_log) }
it "removes old email logs" do
Jobs::CleanUpEmailLogs.new.execute({})
expect(EmailLog.all).to contain_exactly(email_log2, email_log3)
expect(SkippedEmailLog.all).to contain_exactly(skipped_email_log2)
end
it "does not remove old email logs when delete_email_logs_after_days is 0" do
SiteSetting.delete_email_logs_after_days = 0
Jobs::CleanUpEmailLogs.new.execute({})
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