From d6aea126de689767ee6a1454884d7bf2d0ad4387 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 23 Jun 2012 19:39:59 -0300 Subject: Get rid of the clear_i18n hack by using a different locale Use a different and very specific locale for testing currency negative format, and an empty store for currency defaults. --- activesupport/test/number_helper_i18n_test.rb | 30 +++++++++------------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/activesupport/test/number_helper_i18n_test.rb b/activesupport/test/number_helper_i18n_test.rb index bc29b4b2d9..e07198027b 100644 --- a/activesupport/test/number_helper_i18n_test.rb +++ b/activesupport/test/number_helper_i18n_test.rb @@ -49,18 +49,19 @@ module ActiveSupport assert_equal("-10.00 - &$", number_to_currency(-10, :locale => 'ts', :format => "%n - %u")) end - def test_number_to_currency_with_clean_i18n_settings - clean_i18n do - assert_equal("$10.00", number_to_currency(10)) - assert_equal("-$10.00", number_to_currency(-10)) - end + def test_number_to_currency_with_empty_i18n_store + I18n.backend.store_translations 'empty', {} + + assert_equal("$10.00", number_to_currency(10, :locale => 'empty')) + assert_equal("-$10.00", number_to_currency(-10, :locale => 'empty')) end def test_number_to_currency_without_currency_negative_format - clean_i18n do - I18n.backend.store_translations 'ts', :number => { :currency => { :format => { :unit => '@', :format => '%n %u' } } } - assert_equal("-10.00 @", number_to_currency(-10, :locale => 'ts')) - end + I18n.backend.store_translations 'no_negative_format', :number => { + :currency => { :format => { :unit => '@', :format => '%n %u' } } + } + + assert_equal("-10.00 @", number_to_currency(-10, :locale => 'no_negative_format')) end def test_number_with_i18n_precision @@ -109,16 +110,5 @@ module ActiveSupport #Significant was set to true with precision 2, with custom translated units assert_equal "4.3 cm", number_to_human(0.0432, :locale => 'ts', :units => :custom_units_for_number_to_human) end - - private - def clean_i18n - load_path = I18n.load_path.dup - I18n.load_path.clear - I18n.reload! - yield - ensure - I18n.load_path = load_path - I18n.reload! - end end end -- cgit v1.2.3