mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
FIX: Conform EmailLog#bounce_error_code to RFC (#16010)
This commit makes sure that the email log's bounce_error_code conforms to the SMTP error code RFC on save, so that it is always in the format X.X.X or XXX without any additional string details. Also included is a migration to fix this issue for past records.
This commit is contained in:
@ -161,4 +161,21 @@ describe EmailLog do
|
||||
expect(EmailLog.addressed_to_user(user).count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "bounce_error_code fix before update" do
|
||||
fab!(:email_log) { Fabricate(:email_log) }
|
||||
|
||||
it "makes sure the bounce_error_code is in the format X.X.X or XXX" do
|
||||
email_log.update!(bounce_error_code: "5.1.1")
|
||||
expect(email_log.reload.bounce_error_code).to eq("5.1.1")
|
||||
email_log.update!(bounce_error_code: "5.0.0 (permanent failure)")
|
||||
expect(email_log.reload.bounce_error_code).to eq("5.0.0")
|
||||
email_log.update!(bounce_error_code: "422")
|
||||
expect(email_log.reload.bounce_error_code).to eq("422")
|
||||
email_log.update!(bounce_error_code: "5.2")
|
||||
expect(email_log.reload.bounce_error_code).to eq(nil)
|
||||
email_log.update!(bounce_error_code: "blah")
|
||||
expect(email_log.reload.bounce_error_code).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user