Merge pull request #37839 from ttanimichi/modify-inspect-of-activesupport-duration-with-no-parts
The return value of `ActiveSupport::Duration#inspect` is wrong when its parts are empty
This commit is contained in:
commit
461aae05f1
@ -375,7 +375,7 @@ def ago(time = ::Time.current)
|
||||
alias :before :ago
|
||||
|
||||
def inspect #:nodoc:
|
||||
return "0 seconds" if parts.empty?
|
||||
return "#{value} seconds" if parts.empty?
|
||||
|
||||
parts.
|
||||
sort_by { |unit, _ | PARTS.index(unit) }.
|
||||
|
@ -74,6 +74,7 @@ def test_inspect
|
||||
assert_equal "2 weeks", 1.fortnight.inspect
|
||||
assert_equal "0 seconds", (10 % 5.seconds).inspect
|
||||
assert_equal "10 minutes", (10.minutes + 0.seconds).inspect
|
||||
assert_equal "3600 seconds", (1.day / 24).inspect
|
||||
end
|
||||
|
||||
def test_inspect_locale
|
||||
|
Loading…
Reference in New Issue
Block a user