Fix rubocop issue of single- vs double- quotes (+1 squashed commit)

Squashed commits:
[49cb03a3ce] Fix missing return from ActionView::Helpers::NumberHelper#parse_float, fixes #43853
Add test case for number helpers not raising exception when `raise: true` is passed and input is valid
This commit is contained in:
Pedro Moreira 2021-12-13 16:40:09 +00:00
parent 85f45350e6
commit 3edada28fa
No known key found for this signature in database
GPG Key ID: 7A5A176D2BBA90C6
2 changed files with 31 additions and 0 deletions

View File

@ -450,6 +450,7 @@ module ActionView
def parse_float(number, raise_error)
result = Float(number, exception: false)
raise InvalidNumberError, number if result.nil? && raise_error
result
end
end
end

View File

@ -201,4 +201,34 @@ class NumberHelperTest < ActionView::TestCase
end
assert_equal "x", exception.number
end
def test_number_helpers_should_not_raise_error_if_valid_when_specified
assert_nothing_raised do
number_to_human("3.33", raise: true)
end
assert_nothing_raised do
number_to_human_size("3.33", raise: true)
end
assert_nothing_raised do
number_with_precision("3.33", raise: true)
end
assert_nothing_raised do
number_to_currency("3.33", raise: true)
end
assert_nothing_raised do
number_to_percentage("3.33", raise: true)
end
assert_nothing_raised do
number_with_delimiter("3.33", raise: true)
end
assert_nothing_raised do
number_to_phone("3.33", raise: true)
end
end
end