diff options
author | hoffm <m@hof.fm> | 2013-02-20 16:15:59 -0500 |
---|---|---|
committer | hoffm <m@hof.fm> | 2013-02-22 08:25:51 -0500 |
commit | 4e3ceedeba4f95d6f51380277c5562049ccdc264 (patch) | |
tree | 0637fb37a974ab68f97ca5584f22e25b1b56e60e /actionpack | |
parent | 31f807c7aaaf12c16ea1572559c00f49d54d6f43 (diff) | |
download | rails-4e3ceedeba4f95d6f51380277c5562049ccdc264.tar.gz rails-4e3ceedeba4f95d6f51380277c5562049ccdc264.tar.bz2 rails-4e3ceedeba4f95d6f51380277c5562049ccdc264.zip |
Address edge case for number_to_human with units option.
ActiveSupport::NumberHelper#number_to_human now returns the number unaltered when
the units hash does not contain the needed key, e.g. when the number provided is less
than the largest key provided.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/template/number_helper_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb index d8fffe75ed..6a2d5aef18 100644 --- a/actionpack/test/template/number_helper_test.rb +++ b/actionpack/test/template/number_helper_test.rb @@ -266,6 +266,11 @@ class NumberHelperTest < ActionView::TestCase assert_equal '100<script></script>000 Quadrillion', number_to_human(10**20, :delimiter => "<script></script>") end + def test_number_to_human_with_custom_units_that_are_missing_the_needed_key + assert_equal '123', number_to_human(123, :units => {:thousand => 'k'}) + assert_equal '123', number_to_human(123, :units => {}) + end + def test_number_to_human_with_custom_format assert_equal '123 times Thousand', number_to_human(123456, :format => "%n times %u") volume = {:unit => "ml", :thousand => "lt", :million => "m3"} |