Fix ActionView::Helpers::DateHelper#distance_of_time_in_words test #27091

wants to merge 2 commits into


None yet

6 participants

yui-knk commented Nov 18, 2016


The behavior of #round was changed to round to even in Ruby 2.4.
So we have to pass half: :up to #round.

see: ruby/ruby@6ed8c79 and

And for back compatibility, adding core_ext #round to accept options.

@arthurnn arthurnn was assigned by rails-bot Nov 18, 2016

r? @arthurnn

(@rails-bot has picked a reviewer for you, use r? to override)


O_O. Are they aware of this breaking change?


Is this the only place where we use round?

+if !(0.0.round(0, half: :up) rescue false)
+ module ActiveSupport::NumericRoundWithOption
+ def round(ndigits = 0, half: nil)
+ super(ndigits)
matthewd Nov 18, 2016 Member

Accepting the option and then ignoring it seems quite rude.


I opened a bug to get their feedback because changing this in a minor version seems weird

yui-knk added some commits Nov 18, 2016
@yui-knk yui-knk Add `Integer#round` and `Float#round` core extensions
`half` option was added to Integer#round and Float#round in Ruby 2.4.
And a behavior of round was changed to round to even.
We have depended a behavior of rounding to nearest.
In some case (i.e. `ActionView::Helpers::DateHelper#distance_of_time_in_words`),
we have to pass `half: :up` to `round`.

This core_ext enables to us to pass a option,
even before Ruby 2.3.
@yui-knk yui-knk Ensure to round to nearest
The behavior of `#round` was changed to round to even in Ruby 2.4.
So we have to pass `half: :up` to `#round`.

see: ruby/ruby@dfe91fc
yui-knk commented Dec 13, 2016

Also #27177 . This PR is now useless. So I will close this.

@yui-knk yui-knk closed this Dec 13, 2016
@yui-knk yui-knk deleted the yui-knk:fix_round_test branch Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment