]> git.openstreetmap.org Git - rails.git/commitdiff
Add a test for i18n interpolation into plain and html parts
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 2 Dec 2020 13:02:25 +0000 (13:02 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 2 Dec 2020 13:02:25 +0000 (13:02 +0000)
I spent some time working on an alternative translation strategy, without realising some of the plain text implications.

test/mailers/user_mailer_test.rb

index 2a4b5a417a92a834c64d65be825d6fa6ed40b232..537bb9d0ddf60ec4220007d56d3c6986f524be7b 100644 (file)
@@ -17,4 +17,13 @@ class UserMailerTest < ActionMailer::TestCase
 
     assert_match(/one two three/, email.html_part.body.to_s)
   end
+
+  def test_html_encoding
+    user = create(:user, :display_name => "Jack & Jill <br>")
+    message = create(:message, :sender => user)
+    email = UserMailer.message_notification(message)
+
+    assert_match("Jack & Jill <br>", email.text_part.body.to_s)
+    assert_match("Jack &amp; Jill &lt;br&gt;", email.html_part.body.to_s)
+  end
 end