diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index a158947da..18a574c30 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -12,8 +12,20 @@ def add_smtputf8_header end def convert_email_to_punycode + convert_recipient_to_punycode + convert_carbon_copy_to_punycode + convert_blind_carbon_copy_to_punycode + end + + def convert_recipient_to_punycode mail.to = Array(mail.to).map { |email| convert_domain_to_punycode(email) } + end + + def convert_carbon_copy_to_punycode mail.cc = Array(mail.cc).map { |email| convert_domain_to_punycode(email) } + end + + def convert_blind_carbon_copy_to_punycode mail.bcc = Array(mail.bcc).map { |email| convert_domain_to_punycode(email) } end diff --git a/test/integration/users_test.rb b/test/integration/users_test.rb index e5007c31c..51262608c 100644 --- a/test/integration/users_test.rb +++ b/test/integration/users_test.rb @@ -22,31 +22,4 @@ def test_user_is_notified_about_password_change password_confirmation: new_password } } end end - - # def test_user_create_with_punicode - # assert_enqueued_emails 1 do - # post users_path, params: { - # user: { - # email: 'example@ää.eu', - # given_names: 'John', - # surname: 'Doe', - # password: 'password123', - # password_confirmation: 'password123', - # terms_and_conditions_accepted_at: Time.now.utc, - # locale: 'en', - # mobile_phone: '+37269900366', - # identity_code: '60001017793', - # country_code: 'EE', - # accepts_terms_and_conditions: true, - # roles: ['participant'], - # phone_number_confirmed: true, - # provider: 'email'} - # } - # end - - # punicode = SimpleIDN.to_ascii('ää.eu') - # assert User.find_by(email: "example@#{punicode}") - - # assert_redirected_to new_user_session_path - # end end