Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for travel_to with time zone #34766

Merged
merged 1 commit into from
Dec 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions activesupport/test/time_travel_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
require "abstract_unit"
require "active_support/core_ext/date_time"
require "active_support/core_ext/numeric/time"
require "time_zone_test_helpers"

class TimeTravelTest < ActiveSupport::TestCase
include TimeZoneTestHelpers

class TimeSubclass < ::Time; end
class DateSubclass < ::Date; end
class DateTimeSubclass < ::DateTime; end
Expand Down Expand Up @@ -71,6 +74,20 @@ def test_time_helper_travel_to_with_block
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
Time.stub(:now, Time.now) do
begin
Expand Down