aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2017-05-29 10:43:54 -0400
committerGitHub <noreply@github.com>2017-05-29 10:43:54 -0400
commitedc90c858d4cbf1a8e4bfb7347b34348bb30e92c (patch)
tree4eade103e5299c1b749e00d7ee003f892916deac /activesupport/test
parent446a4f7ec2894ea3861b05e385926c0631913987 (diff)
parent202aadd4f4bc0bdce7e376add98c36098ff5086b (diff)
downloadrails-edc90c858d4cbf1a8e4bfb7347b34348bb30e92c.tar.gz
rails-edc90c858d4cbf1a8e4bfb7347b34348bb30e92c.tar.bz2
rails-edc90c858d4cbf1a8e4bfb7347b34348bb30e92c.zip
Merge pull request #26628 from mjhoy/fix-number-to-human-25742
round before calculating exponent in number_to_human_converter
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/number_helper_test.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/test/number_helper_test.rb b/activesupport/test/number_helper_test.rb
index dc0c34d4e2..4caf1428ea 100644
--- a/activesupport/test/number_helper_test.rb
+++ b/activesupport/test/number_helper_test.rb
@@ -321,12 +321,18 @@ module ActiveSupport
gangster = { hundred: "hundred bucks", million: "thousand quids" }
assert_equal "1 hundred bucks", number_helper.number_to_human(100, units: gangster)
assert_equal "25 hundred bucks", number_helper.number_to_human(2500, units: gangster)
+ assert_equal "1000 hundred bucks", number_helper.number_to_human(100_000, units: gangster)
+ assert_equal "1 thousand quids", number_helper.number_to_human(999_999, units: gangster)
+ assert_equal "1 thousand quids", number_helper.number_to_human(1_000_000, units: gangster)
assert_equal "25 thousand quids", number_helper.number_to_human(25000000, units: gangster)
assert_equal "12300 thousand quids", number_helper.number_to_human(12345000000, units: gangster)
#Spaces are stripped from the resulting string
assert_equal "4", number_helper.number_to_human(4, units: { unit: "", ten: "tens " })
assert_equal "4.5 tens", number_helper.number_to_human(45, units: { unit: "", ten: " tens " })
+
+ #Uses only the provided units and does not try to use larger ones
+ assert_equal "1000 kilometers", number_helper.number_to_human(1_000_000, units: { unit: "meter", thousand: "kilometers" })
end
end