diff options
Diffstat (limited to 'test/unit/mail_handler_test.rb')
-rw-r--r-- | test/unit/mail_handler_test.rb | 61 |
1 files changed, 21 insertions, 40 deletions
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 1a3469031..bb91ac3f7 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -411,8 +411,7 @@ class MailHandlerTest < ActiveSupport::TestCase end def test_add_issue_with_japanese_keywords - ja_dev = "\xe9\x96\x8b\xe7\x99\xba" - ja_dev.force_encoding('UTF-8') if ja_dev.respond_to?(:force_encoding) + ja_dev = "\xe9\x96\x8b\xe7\x99\xba".force_encoding('UTF-8') tracker = Tracker.create!(:name => ja_dev) Project.find(1).trackers << tracker issue = submit_email( @@ -447,8 +446,7 @@ class MailHandlerTest < ActiveSupport::TestCase ) assert_kind_of Issue, issue assert_equal 1, issue.attachments.size - ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt" - ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding) + ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt".force_encoding('UTF-8') attachment = issue.attachments.first assert_equal ja, attachment.filename assert_equal 5, attachment.filesize @@ -464,8 +462,7 @@ class MailHandlerTest < ActiveSupport::TestCase ) assert_kind_of Issue, issue assert_equal 1, issue.attachments.size - ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt" - ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding) + ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88.txt".force_encoding('UTF-8') attachment = issue.attachments.first assert_equal ja, attachment.filename assert_equal 5, attachment.filesize @@ -481,10 +478,8 @@ class MailHandlerTest < ActiveSupport::TestCase ) assert_kind_of Issue, issue assert_equal 1, issue.attachments.size - u = "" - u.force_encoding('UTF-8') if u.respond_to?(:force_encoding) - u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc" - u1.force_encoding('UTF-8') if u1.respond_to?(:force_encoding) + u = "".force_encoding('UTF-8') + u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc".force_encoding('UTF-8') 11.times { u << u1 } attachment = issue.attachments.first assert_equal "#{u}.png", attachment.filename @@ -501,10 +496,8 @@ class MailHandlerTest < ActiveSupport::TestCase ) assert_kind_of Issue, issue assert_equal 1, issue.attachments.size - u = "" - u.force_encoding('UTF-8') if u.respond_to?(:force_encoding) - u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc" - u1.force_encoding('UTF-8') if u1.respond_to?(:force_encoding) + u = "".force_encoding('UTF-8') + u1 = "\xc3\x84\xc3\xa4\xc3\x96\xc3\xb6\xc3\x9c\xc3\xbc".force_encoding('UTF-8') 11.times { u << u1 } attachment = issue.attachments.first assert_equal "#{u}.txt", attachment.filename @@ -534,8 +527,7 @@ class MailHandlerTest < ActiveSupport::TestCase 'subject_as_iso-8859-1.eml', :issue => {:project => 'ecookbook'} ) - str = "Testmail from Webmail: \xc3\xa4 \xc3\xb6 \xc3\xbc..." - str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) + str = "Testmail from Webmail: \xc3\xa4 \xc3\xb6 \xc3\xbc...".force_encoding('UTF-8') assert_kind_of Issue, issue assert_equal str, issue.subject end @@ -546,8 +538,7 @@ class MailHandlerTest < ActiveSupport::TestCase :issue => {:project => 'ecookbook'} ) assert_kind_of Issue, issue - str = "Freundliche Gr\xc3\xbcsse" - str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) + str = "Freundliche Gr\xc3\xbcsse".force_encoding('UTF-8') assert_equal str, issue.description end @@ -557,8 +548,7 @@ class MailHandlerTest < ActiveSupport::TestCase :issue => {:project => 'ecookbook'} ) assert_kind_of Issue, issue - str = "Na \xc5\xa1triku se su\xc5\xa1i \xc5\xa1osi\xc4\x87." - str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) + str = "Na \xc5\xa1triku se su\xc5\xa1i \xc5\xa1osi\xc4\x87.".force_encoding('UTF-8') assert issue.description.include?(str) end @@ -568,26 +558,20 @@ class MailHandlerTest < ActiveSupport::TestCase :issue => {:project => 'ecookbook'} ) assert_kind_of Issue, issue - ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88" - ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding) + ja = "\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88".force_encoding('UTF-8') assert_equal ja, issue.subject end def test_add_issue_with_korean_body # Make sure mail bodies with a charset unknown to Ruby # but known to the Mail gem 2.5.4 are handled correctly - kr = "\xEA\xB3\xA0\xEB\xA7\x99\xEC\x8A\xB5\xEB\x8B\x88\xEB\x8B\xA4." - if !kr.respond_to?(:force_encoding) - puts "\nOn Ruby 1.8, skip Korean encoding mail body test" - else - kr.force_encoding('UTF-8') - issue = submit_email( - 'body_ks_c_5601-1987.eml', - :issue => {:project => 'ecookbook'} - ) - assert_kind_of Issue, issue - assert_equal kr, issue.description - end + kr = "\xEA\xB3\xA0\xEB\xA7\x99\xEC\x8A\xB5\xEB\x8B\x88\xEB\x8B\xA4.".force_encoding('UTF-8') + issue = submit_email( + 'body_ks_c_5601-1987.eml', + :issue => {:project => 'ecookbook'} + ) + assert_kind_of Issue, issue + assert_equal kr, issue.description end def test_add_issue_with_no_subject_header @@ -605,8 +589,7 @@ class MailHandlerTest < ActiveSupport::TestCase :issue => {:project => 'ecookbook'} ) assert_kind_of Issue, issue - ja = "Re: \xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88" - ja.force_encoding('UTF-8') if ja.respond_to?(:force_encoding) + ja = "Re: \xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88".force_encoding('UTF-8') assert_equal ja, issue.subject end @@ -910,10 +893,8 @@ class MailHandlerTest < ActiveSupport::TestCase end user = User.order('id DESC').first assert_equal "foo@example.org", user.mail - str1 = "\xc3\x84\xc3\xa4" - str2 = "\xc3\x96\xc3\xb6" - str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding) - str2.force_encoding('UTF-8') if str2.respond_to?(:force_encoding) + str1 = "\xc3\x84\xc3\xa4".force_encoding('UTF-8') + str2 = "\xc3\x96\xc3\xb6".force_encoding('UTF-8') assert_equal str1, user.firstname assert_equal str2, user.lastname end |