mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add test for travel_to
with time zone
This is a regression test for #34751.
This commit is contained in:
parent
1ff2213313
commit
5d905abbe7
1 changed files with 17 additions and 0 deletions
|
@ -3,8 +3,11 @@
|
||||||
require "abstract_unit"
|
require "abstract_unit"
|
||||||
require "active_support/core_ext/date_time"
|
require "active_support/core_ext/date_time"
|
||||||
require "active_support/core_ext/numeric/time"
|
require "active_support/core_ext/numeric/time"
|
||||||
|
require "time_zone_test_helpers"
|
||||||
|
|
||||||
class TimeTravelTest < ActiveSupport::TestCase
|
class TimeTravelTest < ActiveSupport::TestCase
|
||||||
|
include TimeZoneTestHelpers
|
||||||
|
|
||||||
class TimeSubclass < ::Time; end
|
class TimeSubclass < ::Time; end
|
||||||
class DateSubclass < ::Date; end
|
class DateSubclass < ::Date; end
|
||||||
class DateTimeSubclass < ::DateTime; end
|
class DateTimeSubclass < ::DateTime; end
|
||||||
|
@ -71,6 +74,20 @@ class TimeTravelTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_time_helper_travel_to_with_time_zone
|
||||||
|
with_env_tz "US/Eastern" do
|
||||||
|
with_tz_default ActiveSupport::TimeZone["UTC"] do
|
||||||
|
Time.stub(:now, Time.now) do
|
||||||
|
expected_time = 5.minutes.ago
|
||||||
|
|
||||||
|
travel_to 5.minutes.ago do
|
||||||
|
assert_equal expected_time.to_s(:db), Time.zone.now.to_s(:db)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_time_helper_travel_back
|
def test_time_helper_travel_back
|
||||||
Time.stub(:now, Time.now) do
|
Time.stub(:now, Time.now) do
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in a new issue