]> source.dussan.org Git - redmine.git/commitdiff
2.6-stable: fix r13807 on Ruby 1.8.7
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 26 Dec 2014 16:06:44 +0000 (16:06 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 26 Dec 2014 16:06:44 +0000 (16:06 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13817 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/i18n.rb
test/unit/lib/redmine/i18n_test.rb

index 95983198649fcbcc7282ec0aa8528e9d0ae7030b..89dacb0cb752a26ddfbf0313fde2f948f54b1fe3 100644 (file)
@@ -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)
index 1cb7a3d0f0b194c82e32a28a9e0709c659199290..256fcb0e3347c60d9889b59c07eb7d92e246df81 100644 (file)
@@ -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