From: Toshi MARUYAMA Date: Wed, 23 Feb 2011 07:04:52 +0000 (+0000) Subject: scm: add unit RepositoryHelper test for Ruby 1.9 compatibility. X-Git-Tag: 1.2.0~891 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a93d6a1621f10bac5cfb25bcbc109d749deb0d94;p=redmine.git scm: add unit RepositoryHelper test for Ruby 1.9 compatibility. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4932 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/test/unit/helpers/repository_helper_test.rb b/test/unit/helpers/repository_helper_test.rb new file mode 100644 index 000000000..457319a7f --- /dev/null +++ b/test/unit/helpers/repository_helper_test.rb @@ -0,0 +1,68 @@ +# Redmine - project management software +# Copyright (C) 2006-2011 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +require File.expand_path('../../../test_helper', __FILE__) + +class RepositoryHelperTest < HelperTestCase + include RepositoriesHelper + + def test_from_latin1_to_utf8 + with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do + s1 = "Texte encod\xc3\xa9" + s2 = "Texte encod\xe9" + s3 = s2 + if s1.respond_to?(:force_encoding) + s1.force_encoding("UTF-8") + s2.force_encoding("ASCII-8BIT") + s3.force_encoding("UTF-8") + end + assert_equal s1, to_utf8(s2) + assert_equal s1, to_utf8(s3) + end + end + + def test_from_euc_jp_to_utf8 + with_settings :repositories_encodings => 'UTF-8,EUC-JP' do + s1 = "\xe3\x83\xac\xe3\x83\x83\xe3\x83\x89\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\xb3" + s2 = "\xa5\xec\xa5\xc3\xa5\xc9\xa5\xde\xa5\xa4\xa5\xf3" + s3 = s2 + if s1.respond_to?(:force_encoding) + s1.force_encoding("UTF-8") + s2.force_encoding("ASCII-8BIT") + s3.force_encoding("UTF-8") + end + assert_equal s1, to_utf8(s2) + assert_equal s1, to_utf8(s3) + end + end + + def test_to_utf8_should_be_converted_all_latin1_to_utf8 + with_settings :repositories_encodings => 'ISO-8859-1' do + s1 = "\xc3\x82\xc2\x80" + s2 = "\xC2\x80" + s3 = s2 + if s1.respond_to?(:force_encoding) + s1.force_encoding("UTF-8") + s2.force_encoding("ASCII-8BIT") + s3.force_encoding("UTF-8") + end + assert_equal s1, to_utf8(s2) + assert_equal s1, to_utf8(s3) + end + end +end +