diff options
author | Go MAEDA <maeda@farend.jp> | 2019-03-19 15:43:55 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-03-19 15:43:55 +0000 |
commit | 26509e7f4c6dae94baf291b95d46eb6ec8ebca0b (patch) | |
tree | eca8843de4ca00c229612e8f4f323a5474444a29 /test/unit/changeset_test.rb | |
parent | 7d2f10ccac0e51a8eb337ed388ab8182df4c25e1 (diff) | |
download | redmine-26509e7f4c6dae94baf291b95d46eb6ec8ebca0b.tar.gz redmine-26509e7f4c6dae94baf291b95d46eb6ec8ebca0b.zip |
Decode hexadecimal-encoded literals in order to be frozen string literals friendly (#31004).
Patch by Yuichi HARADA.
git-svn-id: http://svn.redmine.org/redmine/trunk@17991 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/changeset_test.rb')
-rw-r--r-- | test/unit/changeset_test.rb | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index b085ce00a..24dbf1bf4 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -448,8 +448,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.".force_encoding("ASCII-8BIT") + str = (+"Texte encod\xe9 en ISO-8859-1.").force_encoding("ASCII-8BIT") r = Repository::Bazaar.create!( :project => proj, :url => '/tmp/test/bazaar', @@ -461,15 +460,12 @@ class ChangesetTest < ActiveSupport::TestCase :scmid => '12345', :comments => str) assert( c.save ) - str_utf8 = "Texte encod\xc3\xa9 en ISO-8859-1.".force_encoding("UTF-8") - assert_equal str_utf8, c.comments + assert_equal 'Texte encodé en ISO-8859-1.', 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.".force_encoding("UTF-8") - str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT") + str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT") r = Repository::Bazaar.create!( :project => proj, :url => '/tmp/test/bazaar', @@ -479,7 +475,7 @@ class ChangesetTest < ActiveSupport::TestCase :committed_on => Time.now, :revision => '123', :scmid => '12345', - :comments => str1, + :comments => "Texte encod\xE9 en ISO-8859-1.", :committer => str2) assert( c.save ) assert_equal "Texte encod? en ISO-8859-1.", c.comments @@ -488,7 +484,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".force_encoding('ASCII-8BIT') + str = (+"test\xb5\xfetest\xb5\xfe").force_encoding('ASCII-8BIT') r = Repository::Bazaar.create!( :project => proj, :url => '/tmp/test/bazaar', @@ -504,8 +500,8 @@ class ChangesetTest < ActiveSupport::TestCase end def test_comments_should_be_converted_all_latin1_to_utf8 - s1 = "\xC2\x80" - s2 = "\xc3\x82\xc2\x80" + s1 = +"\xC2\x80" + s2 = +"\xc3\x82\xc2\x80" s4 = s2.dup s3 = s1.dup s1.force_encoding('ASCII-8BIT') @@ -530,8 +526,7 @@ 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".force_encoding("UTF-8") - str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".force_encoding("ASCII-8BIT") + str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT") r = Repository::Bazaar.create!( :project => proj, :url => '/tmp/test/bazaar', @@ -547,7 +542,7 @@ class ChangesetTest < ActiveSupport::TestCase ch = Change.new( :changeset => cs, :action => "A", - :path => str1, + :path => "Texte encod\xE9 en ISO-8859-1", :from_path => str2, :from_revision => "345") assert(ch.save) |