aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-12-21 09:20:08 +0900
committerYuji Yaginuma <yuuji.yaginuma@gmail.com>2018-12-21 10:08:33 +0900
commit5d905abbe77295e65c88b50940af4bfb99a48482 (patch)
tree8622bca44b393756d8b00afa8bffae7b465933e7 /activesupport/test
parent1ff22133139b3c8aa4fb9b691b677aa0e697ea77 (diff)
downloadrails-5d905abbe77295e65c88b50940af4bfb99a48482.tar.gz
rails-5d905abbe77295e65c88b50940af4bfb99a48482.tar.bz2
rails-5d905abbe77295e65c88b50940af4bfb99a48482.zip
Add test for `travel_to` with time zone
This is a regression test for #34751.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/time_travel_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/activesupport/test/time_travel_test.rb b/activesupport/test/time_travel_test.rb
index 8c47f2cdc7..fbd33a6036 100644
--- a/activesupport/test/time_travel_test.rb
+++ b/activesupport/test/time_travel_test.rb
@@ -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
@@ -71,6 +74,20 @@ class TimeTravelTest < ActiveSupport::TestCase
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