From 249232f6590394103494aa83075cc5c38efa0e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 9 Feb 2021 03:49:59 +0000 Subject: [PATCH] Fix warning with Ruby 2.7 on Time.at with keyword arguments Closes #41375 --- .../lib/active_support/core_ext/time/calculations.rb | 4 ++-- activesupport/test/core_ext/time_ext_test.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 9c9f26047f..2afbc2adb9 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -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 diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 31d33ca383..10ef69bd60 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -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"])