FIX: Rejected emails should not be cleaned up before their logs (#17648)

* FIX: Rejected emails should not be cleaned up before their logs

If we delete the rejected emails before we delete their associated logs
we will receive 404 errors trying to inspect an email message for that
log.

* don't add a blank line

* test for max value as well

* pr cleanup and add migration

* Fix failing test
This commit is contained in:
Blake Erickson
2022-07-27 07:28:44 +01:00
committed by GitHub
parent 3bd5f2d411
commit 8b08b9a763
5 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
describe DeleteRejectedEmailAfterDaysValidator do
it 'is not valid if value is smaller than the value of SiteSetting.delete_email_logs_after_days' do
SiteSetting.delete_email_logs_after_days = 90
expect { SiteSetting.delete_rejected_email_after_days = 89 }.to raise_error(Discourse::InvalidParameters)
end
it "is not valid if value is greater than #{DeleteRejectedEmailAfterDaysValidator::MAX}" do
expect { SiteSetting.delete_rejected_email_after_days = DeleteRejectedEmailAfterDaysValidator::MAX + 1 }.to raise_error(Discourse::InvalidParameters)
end
end