summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-04-09 09:31:14 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-04-09 09:31:14 +0000
commit6536c53e09735f81b11eeb70a744a94c48e0c977 (patch)
treeeed94ea69e06417b40f13c6b057fc7d06dc3614d /test/unit
parentb9ce061319133748c48c255bf6bd17b7dfe5ed9d (diff)
downloadredmine-6536c53e09735f81b11eeb70a744a94c48e0c977.tar.gz
redmine-6536c53e09735f81b11eeb70a744a94c48e0c977.zip
scm: replace invalid utf-8 sequences in comments instead of stripping on Ruby 1.8.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5373 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/changeset_test.rb32
1 files changed, 13 insertions, 19 deletions
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb
index 93027d849..8e98b0574 100644
--- a/test/unit/changeset_test.rb
+++ b/test/unit/changeset_test.rb
@@ -21,7 +21,8 @@ require File.expand_path('../../test_helper', __FILE__)
class ChangesetTest < ActiveSupport::TestCase
fixtures :projects, :repositories, :issues, :issue_statuses,
- :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :users, :members, :member_roles, :trackers
+ :changesets, :changes, :issue_categories, :enumerations,
+ :custom_fields, :custom_values, :users, :members, :member_roles, :trackers
def setup
end
@@ -250,29 +251,26 @@ class ChangesetTest < ActiveSupport::TestCase
assert_equal str_utf8, c.comments
end
- def test_invalid_utf8_sequences_in_comments_should_be_stripped
+ 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")
str = "Texte encod\xe9 en ISO-8859-1."
str.force_encoding("ASCII-8BIT") if str.respond_to?(:force_encoding)
r = Repository::Bazaar.create!(
- :project => proj, :url => '/tmp/test/bazaar',
+ :project => proj,
+ :url => '/tmp/test/bazaar',
:log_encoding => 'UTF-8' )
assert r
- c = Changeset.new(:repository => r,
+ c = Changeset.new(:repository => r,
:committed_on => Time.now,
- :revision => '123',
- :scmid => '12345',
- :comments => str)
+ :revision => '123',
+ :scmid => '12345',
+ :comments => str)
assert( c.save )
- if str.respond_to?(:force_encoding)
- assert_equal "Texte encod? en ISO-8859-1.", c.comments
- else
- assert_equal "Texte encod en ISO-8859-1.", c.comments
- end
+ assert_equal "Texte encod? en ISO-8859-1.", c.comments
end
- def test_invalid_utf8_sequences_in_comments_should_be_stripped_ja_jis
+ 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)
@@ -280,7 +278,7 @@ class ChangesetTest < ActiveSupport::TestCase
end
r = Repository::Bazaar.create!(
:project => proj,
- :url => '/tmp/test/bazaar',
+ :url => '/tmp/test/bazaar',
:log_encoding => 'ISO-2022-JP' )
assert r
c = Changeset.new(:repository => r,
@@ -289,11 +287,7 @@ class ChangesetTest < ActiveSupport::TestCase
:scmid => '12345',
:comments => str)
assert( c.save )
- if str.respond_to?(:force_encoding)
- assert_equal "test??test??", c.comments
- else
- assert_equal "testtest", c.comments
- end
+ assert_equal "test??test??", c.comments
end
def test_comments_should_be_converted_all_latin1_to_utf8