aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/number_helper_i18n_test.rb24
1 files changed, 19 insertions, 5 deletions
diff --git a/actionpack/test/template/number_helper_i18n_test.rb b/actionpack/test/template/number_helper_i18n_test.rb
index 2528bead36..3fdf991a44 100644
--- a/actionpack/test/template/number_helper_i18n_test.rb
+++ b/actionpack/test/template/number_helper_i18n_test.rb
@@ -10,7 +10,9 @@ class NumberHelperI18nTests < Test::Unit::TestCase
@number_defaults = { :precision => 3, :delimiter => ',', :separator => '.' }
@currency_defaults = { :unit => '$', :format => '%u%n', :precision => 2 }
@human_defaults = { :precision => 1 }
- @human_storage_units_defaults = %w(Bytes KB MB GB TB)
+ @human_storage_units_format_default = "%n %u"
+ @human_storage_units_units_byte_other = "Bytes"
+ @human_storage_units_units_kb_other = "KB"
@percentage_defaults = { :delimiter => '' }
@precision_defaults = { :delimiter => '' }
@@ -48,10 +50,22 @@ class NumberHelperI18nTests < Test::Unit::TestCase
I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults)
I18n.expects(:translate).with(:'number.human.format', :locale => 'en',
:raise => true).returns(@human_defaults)
- I18n.expects(:translate).with(:'number.human.storage_units', :locale => 'en',
- :raise => true).returns(@human_storage_units_defaults)
- # can't be called with 1 because this directly returns without calling I18n.translate
- number_to_human_size(1025, :locale => 'en')
+ I18n.expects(:translate).with(:'number.human.storage_units.format', :locale => 'en',
+ :raise => true).returns(@human_storage_units_format_default)
+ I18n.expects(:translate).with(:'number.human.storage_units.units.kb', :locale => 'en', :count => 2,
+ :raise => true).returns(@human_storage_units_units_kb_other)
+ # 2KB
+ number_to_human_size(2048, :locale => 'en')
+
+ I18n.expects(:translate).with(:'number.format', :locale => 'en', :raise => true).returns(@number_defaults)
+ I18n.expects(:translate).with(:'number.human.format', :locale => 'en',
+ :raise => true).returns(@human_defaults)
+ I18n.expects(:translate).with(:'number.human.storage_units.format', :locale => 'en',
+ :raise => true).returns(@human_storage_units_format_default)
+ I18n.expects(:translate).with(:'number.human.storage_units.units.byte', :locale => 'en', :count => 42,
+ :raise => true).returns(@human_storage_units_units_byte_other)
+ # 42 Bytes
+ number_to_human_size(42, :locale => 'en')
end
end
end