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:
Ryuta Kamizono 2019-12-01 00:19:17 +09:00 committed by GitHub
commit 461aae05f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

@ -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