aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJack Xu <jackxxu@gmail.com>2013-08-28 23:46:53 -0500
committerJack Xu <jackxxu@gmail.com>2013-08-28 23:46:53 -0500
commit24a7e609437d9e6ea61140492461631c4d5bd665 (patch)
tree4eeca3b4a541801d7e9d674fbb34c999e6341100 /activesupport/test
parent4934f19a7812b08a369c775c724410057daeb151 (diff)
downloadrails-24a7e609437d9e6ea61140492461631c4d5bd665.tar.gz
rails-24a7e609437d9e6ea61140492461631c4d5bd665.tar.bz2
rails-24a7e609437d9e6ea61140492461631c4d5bd665.zip
Enable number_to_percentage to keep the number's precision by allowing :precision to be nil
number_helper.number_to_percentage(1000, precision: nil) # => "1000%"
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/number_helper_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/test/number_helper_test.rb b/activesupport/test/number_helper_test.rb
index 1fadef3637..a30e8178c7 100644
--- a/activesupport/test/number_helper_test.rb
+++ b/activesupport/test/number_helper_test.rb
@@ -79,6 +79,10 @@ module ActiveSupport
assert_equal("123.4%", number_helper.number_to_percentage(123.400, :precision => 3, :strip_insignificant_zeros => true))
assert_equal("1.000,000%", number_helper.number_to_percentage(1000, :delimiter => '.', :separator => ','))
assert_equal("1000.000 %", number_helper.number_to_percentage(1000, :format => "%n %"))
+ assert_equal("1000%", number_helper.number_to_percentage(1000, precision: nil))
+ assert_equal("1000%", number_helper.number_to_percentage(1000, precision: nil))
+ assert_equal("1000.1%", number_helper.number_to_percentage(1000.1, precision: nil))
+ assert_equal("-0.13 %", number_helper.number_to_percentage("-0.13", precision: nil, :format => "%n %"))
end
end