Encode domain parts of all addresses in mailers as punycode

This commit is contained in:
Artur Beljajev 2019-04-13 20:05:07 +03:00 committed by --global
parent 25d5d12cfe
commit 86b7b1d19f
4 changed files with 46 additions and 7 deletions

View file

@ -14,4 +14,22 @@ class ApplicationMailerTest < ActiveSupport::TestCase
assert_equal ['no-reply@registry.test'], email.from
end
def test_encodes_address_fields_as_punycode
mailer = Class.new(ApplicationMailer) do
def test
# Empty block to avoid template rendering
mail(from: 'from@münchen.test', to: 'to@münchen.test', cc: 'cc@münchen.test',
bcc: 'bcc@münchen.test') {}
end
end
email = mailer.test
email.deliver_now
assert_equal ['from@xn--mnchen-3ya.test'], email.from
assert_equal ['to@xn--mnchen-3ya.test'], email.to
assert_equal ['cc@xn--mnchen-3ya.test'], email.cc
assert_equal ['bcc@xn--mnchen-3ya.test'], email.bcc
end
end