diff options
Diffstat (limited to 'test/unit/changeset_test.rb')
-rw-r--r-- | test/unit/changeset_test.rb | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index 0467d59a1..eee7da81c 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -388,8 +388,7 @@ class ChangesetTest < ActiveSupport::TestCase def test_comments_should_be_converted_to_utf8 proj = Project.find(3) # str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt") - str = "Texte encod\xe9 en ISO-8859-1." - str.force_encoding("ASCII-8BIT") if str.respond_to?(:force_encoding) + str = "Texte encod\xe9 en ISO-8859-1.".force_encoding("ASCII-8BIT") r = Repository::Bazaar.create!( :project => proj, :url => '/tmp/test/bazaar', @@ -401,18 +400,15 @@ class ChangesetTest < ActiveSupport::TestCase :scmid => '12345', :comments => str) assert( c.save ) - str_utf8 = "Texte encod\xc3\xa9 en ISO-8859-1." - str_utf8.force_encoding("UTF-8") if str_utf8.respond_to?(:force_encoding) + str_utf8 = "Texte encod\xc3\xa9 en ISO-8859-1.".force_encoding("UTF-8") assert_equal str_utf8, c.comments end def test_invalid_utf8_sequences_in_comments_should_be_replaced_latin1 proj = Project.find(3) # str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt") - str1 = "Texte encod\xe9 en ISO-8859-1." - str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test" - str1.force_encoding("UTF-8") if str1.respond_to?(:force_encoding) - str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding) + str1 = "Texte encod\xe9 en ISO-8859-1.".force_encoding("UTF-8") + str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT") r = Repository::Bazaar.create!( :project => proj, :url => '/tmp/test/bazaar', @@ -431,10 +427,7 @@ class ChangesetTest < ActiveSupport::TestCase def test_invalid_utf8_sequences_in_comments_should_be_replaced_ja_jis proj = Project.find(3) - str = "test\xb5\xfetest\xb5\xfe" - if str.respond_to?(:force_encoding) - str.force_encoding('ASCII-8BIT') - end + str = "test\xb5\xfetest\xb5\xfe".force_encoding('ASCII-8BIT') r = Repository::Bazaar.create!( :project => proj, :url => '/tmp/test/bazaar', @@ -453,14 +446,12 @@ class ChangesetTest < ActiveSupport::TestCase s1 = "\xC2\x80" s2 = "\xc3\x82\xc2\x80" s4 = s2.dup - if s1.respond_to?(:force_encoding) - s3 = s1.dup - s1.force_encoding('ASCII-8BIT') - s2.force_encoding('ASCII-8BIT') - s3.force_encoding('ISO-8859-1') - s4.force_encoding('UTF-8') - assert_equal s3.encode('UTF-8'), s4 - end + s3 = s1.dup + s1.force_encoding('ASCII-8BIT') + s2.force_encoding('ASCII-8BIT') + s3.force_encoding('ISO-8859-1') + s4.force_encoding('UTF-8') + assert_equal s3.encode('UTF-8'), s4 proj = Project.find(3) r = Repository::Bazaar.create!( :project => proj, @@ -478,10 +469,8 @@ class ChangesetTest < ActiveSupport::TestCase def test_invalid_utf8_sequences_in_paths_should_be_replaced proj = Project.find(3) - str1 = "Texte encod\xe9 en ISO-8859-1" - str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test" - str1.force_encoding("UTF-8") if str1.respond_to?(:force_encoding) - str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding) + str1 = "Texte encod\xe9 en ISO-8859-1".force_encoding("UTF-8") + str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT") r = Repository::Bazaar.create!( :project => proj, :url => '/tmp/test/bazaar', @@ -521,9 +510,7 @@ class ChangesetTest < ActiveSupport::TestCase assert( c.save ) assert_equal "", c.comments assert_equal nil, c.committer - if c.comments.respond_to?(:force_encoding) - assert_equal "UTF-8", c.comments.encoding.to_s - end + assert_equal "UTF-8", c.comments.encoding.to_s end def test_comments_empty @@ -542,10 +529,8 @@ class ChangesetTest < ActiveSupport::TestCase assert( c.save ) assert_equal "", c.comments assert_equal "", c.committer - if c.comments.respond_to?(:force_encoding) - assert_equal "UTF-8", c.comments.encoding.to_s - assert_equal "UTF-8", c.committer.encoding.to_s - end + assert_equal "UTF-8", c.comments.encoding.to_s + assert_equal "UTF-8", c.committer.encoding.to_s end def test_comments_should_accept_more_than_64k |