aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-23 19:39:59 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-06-24 19:30:06 -0300
commitd6aea126de689767ee6a1454884d7bf2d0ad4387 (patch)
tree27d9438b73c81024405c194dac1bd2f8b8f37777
parentdc766c9e7b727cbd0b8ff5c6c706b955b6dfa632 (diff)
downloadrails-d6aea126de689767ee6a1454884d7bf2d0ad4387.tar.gz
rails-d6aea126de689767ee6a1454884d7bf2d0ad4387.tar.bz2
rails-d6aea126de689767ee6a1454884d7bf2d0ad4387.zip
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.
-rw-r--r--activesupport/test/number_helper_i18n_test.rb30
1 files 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