aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/number_helper_test.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-01-25 10:30:32 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-01-25 10:51:00 -0200
commit74fabdf6c4c00827c657b4d6cef9ae6b96d3d0d2 (patch)
tree2aa77c41c5dd652b790d5dca1e46890931b562b9 /actionpack/test/template/number_helper_test.rb
parentc753e3af764f4888bc71720741158863b23d63c1 (diff)
downloadrails-74fabdf6c4c00827c657b4d6cef9ae6b96d3d0d2.tar.gz
rails-74fabdf6c4c00827c657b4d6cef9ae6b96d3d0d2.tar.bz2
rails-74fabdf6c4c00827c657b4d6cef9ae6b96d3d0d2.zip
Do not mutate given options hash in number helpers
Diffstat (limited to 'actionpack/test/template/number_helper_test.rb')
-rw-r--r--actionpack/test/template/number_helper_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb
index ca897a48cc..482d953907 100644
--- a/actionpack/test/template/number_helper_test.rb
+++ b/actionpack/test/template/number_helper_test.rb
@@ -268,6 +268,31 @@ class NumberHelperTest < ActionView::TestCase
assert_nil number_to_human(nil)
end
+ def test_number_helpers_do_not_mutate_options_hash
+ options = { 'raise' => true }
+
+ number_to_phone(1, options)
+ assert_equal({ 'raise' => true }, options)
+
+ number_to_currency(1, options)
+ assert_equal({ 'raise' => true }, options)
+
+ number_to_percentage(1, options)
+ assert_equal({ 'raise' => true }, options)
+
+ number_with_delimiter(1, options)
+ assert_equal({ 'raise' => true }, options)
+
+ number_with_precision(1, options)
+ assert_equal({ 'raise' => true }, options)
+
+ number_to_human_size(1, options)
+ assert_equal({ 'raise' => true }, options)
+
+ number_to_human(1, options)
+ assert_equal({ 'raise' => true }, options)
+ end
+
def test_number_helpers_should_return_non_numeric_param_unchanged
assert_equal("+1-x x 123", number_to_phone("x", :country_code => 1, :extension => 123))
assert_equal("x", number_to_phone("x"))