Browse Source

Added <p> test for html_mail_client_fixes().

Martin Edenhofer 8 years ago
parent
commit
c6f09e8867
2 changed files with 15 additions and 5 deletions
  1. 3 3
      app/models/channel/email_build.rb
  2. 12 2
      test/unit/email_build_test.rb

+ 3 - 3
app/models/channel/email_build.rb

@@ -241,9 +241,9 @@ Add/change markup to display html in any mail client nice.
   def self.html_mail_client_fixes(html)
 
     # https://github.com/martini/zammad/issues/165
-    html.gsub!('<blockquote type="cite">', '<blockquote type="cite" style="border-left: 2px solid blue; margin: 0px; padding: 8px 12px 8px 12px;">')
-    html.gsub('<p>', '<p style="margin: 0;">')
-
+    new_html = html.gsub('<blockquote type="cite">', '<blockquote type="cite" style="border-left: 2px solid blue; margin: 0px; padding: 8px 12px 8px 12px;">')
+    new_html.gsub!('<p>', '<p style="margin: 0;">')
+    new_html
   end
 
 end

+ 12 - 2
test/unit/email_build_test.rb

@@ -175,7 +175,6 @@ text
 text
 </blockquote>'
     html_with_fixes = Channel::EmailBuild.html_mail_client_fixes(html_raw)
-
     assert_not_equal(html_with_fixes, html_raw)
 
     html_should = '<blockquote type="cite" style="border-left: 2px solid blue; margin: 0px; padding: 8px 12px 8px 12px;">some
@@ -187,9 +186,20 @@ text
 <blockquote type="cite" style="border-left: 2px solid blue; margin: 0px; padding: 8px 12px 8px 12px;">some
 text
 </blockquote>'
-
     assert_equal(html_should, html_with_fixes)
 
+    html_raw = '<p>some
+text
+</p>
+<p>123</p>'
+    html_with_fixes = Channel::EmailBuild.html_mail_client_fixes(html_raw)
+    assert_not_equal(html_with_fixes, html_raw)
+
+    html_should = '<p style="margin: 0;">some
+text
+</p>
+<p style="margin: 0;">123</p>'
+    assert_equal(html_should, html_with_fixes)
   end
 
 end