discourse/spec/tasks/incoming_emails_spec.rb
Krzysztof Kotlarek c32bd8ae48 FEATURE: Remove attachments and truncate raw field for incoming emails (#8253)
Adds the settings: 

raw_email_max_length, raw_rejected_email_max_length, delete_rejected_email_after_days. 

These settings control retention of the "raw" emails logs.

raw_email_max_length ensures that if we get incoming email that is huge we will truncate it removing uploads from the raw log.

raw_rejected_email_max_length introduces an even more aggressive truncation for rejected incoming mail. 

delete_rejected_email_after_days controls how many days we will keep rejected emails for (default 90)
2019-10-30 16:54:35 +11:00

26 lines
747 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe "incoming emails tasks" do
before do
Rake::Task.clear
Discourse::Application.load_tasks
end
describe 'email with attachment' do
fab!(:incoming_email) { Fabricate(:incoming_email, raw: email(:attached_txt_file)) }
it 'updates record' do
expect { Rake::Task['incoming_emails:truncate_long'].invoke }.to change { incoming_email.reload.raw }
end
end
describe 'short email without attachment' do
fab!(:incoming_email) { Fabricate(:incoming_email, raw: email(:html_reply)) }
it 'does not update record' do
expect { Rake::Task['incoming_emails:truncate_long'].invoke }.not_to change { incoming_email.reload.raw }
end
end
end