# encoding: utf-8 require 'test_helper' class EmailBuildTest < ActiveSupport::TestCase test 'document complete check' do html = 'test' result = Channel::EmailBuild.html_complete_check( html ) assert( result =~ /^<\!DOCTYPE/, 'test 1') assert( result !~ /^.+?<\!DOCTYPE/, 'test 1') assert( result =~ //, 'test 1') assert( result =~ /font-family/, 'test 1') assert( result =~ /test<\/b>/, 'test 1') html = 'invalid test' result = Channel::EmailBuild.html_complete_check( html ) assert( result !~ /^<\!DOCTYPE/, 'test 2') assert( result =~ /^.+?<\!DOCTYPE/, 'test 2') assert( result =~ //, 'test 2') assert( result !~ /font-family/, 'test 2') assert( result =~ /test<\/b>/, 'test 2') end test 'html email check' do html = '
> Welcome!
>
> Thank you for installing Zammad.
>
' mail = Channel::EmailBuild.build( :from => 'sender@example.com', :to => 'recipient@example.com', :body => html, :content_type => 'text/html', ) should = '> Welcome! > > Thank you for installing Zammad. > ' assert_equal( should, mail.text_part.body.to_s ) assert_equal( html, mail.html_part.body.to_s ) end test 'html2text' do html = '
> Welcome!
>
> Thank you for installing Zammad.
>
' should = '> Welcome! > > Thank you for installing Zammad. > ' assert_equal( should, html.html2text ) html = ' line 1
you
-----&' should = 'line 1 you -----&' assert_equal( should, html.html2text ) html = ' ' should = '* #1 * #2' assert_equal( should, html.html2text ) end end