mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #15072 from mjtko/fix/issue-15064
[Fixes #15064] Calling number_to_delimited on a ActiveSupport::SafeBuffer results in mangled output
This commit is contained in:
commit
2b84eea9c0
3 changed files with 14 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
* Fixed an issue when using
|
||||
`ActiveSupport::NumberHelper::NumberToDelimitedConverter` to
|
||||
convert a value that is an `ActiveSupport::SafeBuffer` introduced
|
||||
in 2da9d67.
|
||||
|
||||
For more info see #15064.
|
||||
|
||||
*Mark J. Titorenko*
|
||||
|
||||
* `TimeZone#parse` defaults the day of the month to '1' if any other date
|
||||
components are specified. This is more consistent with the behavior of
|
||||
`Time#parse`.
|
||||
|
|
|
@ -13,7 +13,9 @@ module ActiveSupport
|
|||
|
||||
def parts
|
||||
left, right = number.to_s.split('.')
|
||||
left.gsub!(DELIMITED_REGEX) { "#{$1}#{options[:delimiter]}" }
|
||||
left.gsub!(DELIMITED_REGEX) do |digit_to_delimit|
|
||||
"#{digit_to_delimit}#{options[:delimiter]}"
|
||||
end
|
||||
[left, right].compact
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require 'abstract_unit'
|
||||
require 'active_support/number_helper'
|
||||
require 'active_support/core_ext/string/output_safety'
|
||||
|
||||
module ActiveSupport
|
||||
module NumberHelper
|
||||
|
@ -97,6 +98,7 @@ module ActiveSupport
|
|||
assert_equal("123,456,789.78901", number_helper.number_to_delimited(123456789.78901))
|
||||
assert_equal("0.78901", number_helper.number_to_delimited(0.78901))
|
||||
assert_equal("123,456.78", number_helper.number_to_delimited("123456.78"))
|
||||
assert_equal("123,456.78", number_helper.number_to_delimited("123456.78".html_safe))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue