From c91ce512a9e2a2d92c818b467fb4773857bc8ca7 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Wed, 26 Sep 2012 08:45:39 +0000 Subject: [PATCH] fix number_to_currency() raises exception on Rails3 bs and de locale (#11922) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10476 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- config/locales/bs.yml | 5 ++--- config/locales/de.yml | 4 +--- test/unit/lib/redmine/i18n_test.rb | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/config/locales/bs.yml b/config/locales/bs.yml index 9f9590ea1..51cbd6040 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -80,9 +80,8 @@ bs: format: unit: 'KM' format: '%u %n' - separator: - delimiter: - precision: + negative_format: '%u -%n' + delimiter: '' percentage: format: delimiter: "" diff --git a/config/locales/de.yml b/config/locales/de.yml index be60c3a2b..24ad191ae 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -84,9 +84,7 @@ de: format: unit: '€' format: '%n %u' - separator: - delimiter: - precision: + delimiter: '' percentage: format: delimiter: "" diff --git a/test/unit/lib/redmine/i18n_test.rb b/test/unit/lib/redmine/i18n_test.rb index d234ddf3c..046ae2336 100644 --- a/test/unit/lib/redmine/i18n_test.rb +++ b/test/unit/lib/redmine/i18n_test.rb @@ -171,6 +171,24 @@ class Redmine::I18nTest < ActiveSupport::TestCase assert_equal 'j', day_letter(4) end + def test_number_to_currency_for_each_language + valid_languages.each do |lang| + set_language_if_valid lang + assert_nothing_raised "#{lang} failure" do + number_to_currency(-1000.2) + end + end + end + + def test_number_to_currency_default + set_language_if_valid 'bs' + assert_equal "KM -1000,20", number_to_currency(-1000.2) + set_language_if_valid 'de' + euro_sign = "\xe2\x82\xac" + euro_sign.force_encoding('UTF-8') if euro_sign.respond_to?(:force_encoding) + assert_equal "-1000,20 #{euro_sign}", number_to_currency(-1000.2) + end + def test_valid_languages assert valid_languages.is_a?(Array) assert valid_languages.first.is_a?(Symbol)