From: Toshi MARUYAMA Date: Fri, 26 Dec 2014 16:06:44 +0000 (+0000) Subject: 2.6-stable: fix r13807 on Ruby 1.8.7 X-Git-Tag: 2.6.1~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=158a01f2b7a83c634827c220d7d27c507672d740;p=redmine.git 2.6-stable: fix r13807 on Ruby 1.8.7 git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13817 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb index 959831986..89dacb0cb 100644 --- a/lib/redmine/i18n.rb +++ b/lib/redmine/i18n.rb @@ -103,7 +103,13 @@ module Redmine languages_options :cache => false end end - options.map {|name, lang| [name.force_encoding("UTF-8"), lang.force_encoding("UTF-8")]} + options.map do |name, lang| + n = name + l = lang + n.force_encoding("UTF-8") if n.respond_to?(:force_encoding) + l.force_encoding("UTF-8") if l.respond_to?(:force_encoding) + [n, l] + end end def find_language(lang) diff --git a/test/unit/lib/redmine/i18n_test.rb b/test/unit/lib/redmine/i18n_test.rb index 1cb7a3d0f..256fcb0e3 100644 --- a/test/unit/lib/redmine/i18n_test.rb +++ b/test/unit/lib/redmine/i18n_test.rb @@ -199,8 +199,10 @@ class Redmine::I18nTest < ActiveSupport::TestCase end def test_languages_options_should_return_strings_with_utf8_encoding - strings = languages_options.flatten - assert_equal ["UTF-8"], strings.map(&:encoding).uniq.map(&:name).sort + if "".respond_to?(:force_encoding) + strings = languages_options.flatten + assert_equal ["UTF-8"], strings.map(&:encoding).uniq.map(&:name).sort + end end def test_languages_options_should_ignore_locales_without_general_lang_name_key