Fix warning with Ruby 2.7 on Time.at with keyword arguments

Closes #41375
This commit is contained in:
Rafael Mendonça França 2021-02-09 03:49:59 +00:00
parent 5d10e8e343
commit 249232f659
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
2 changed files with 6 additions and 2 deletions

View File

@ -42,8 +42,8 @@ class Time
# Layers additional behavior on Time.at so that ActiveSupport::TimeWithZone and DateTime
# instances can be used when called with a single argument
def at_with_coercion(*args)
return at_without_coercion(*args) if args.size != 1
def at_with_coercion(*args, **kwargs)
return at_without_coercion(*args, **kwargs) if args.size != 1 || !kwargs.empty?
# Time.at can be called with a time or numerical value
time_or_number = args.first

View File

@ -919,6 +919,10 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
end
end
def test_at_with_in_option
assert_equal Time.new(1970, 1, 1, 0, 42, 17, "-08:00"), Time.at(31337, in: -28800)
end
def test_at_with_time_with_zone_returns_local_time
with_env_tz "US/Eastern" do
twz = ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 0), ActiveSupport::TimeZone["London"])