diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/time_travel_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activesupport/test/time_travel_test.rb b/activesupport/test/time_travel_test.rb index 616015b74e..148aa5ef7f 100644 --- a/activesupport/test/time_travel_test.rb +++ b/activesupport/test/time_travel_test.rb @@ -163,4 +163,26 @@ class TimeTravelTest < ActiveSupport::TestCase assert_equal DateTime.now.to_s, DateTimeSubclass.now.to_s end end + + def test_time_helper_freeze_time + expected_time = Time.now + freeze_time + sleep(1) + + assert_equal expected_time.to_s(:db), Time.now.to_s(:db) + ensure + travel_back + end + + def test_time_helper_freeze_time_with_block + expected_time = Time.now + + freeze_time do + sleep(1) + + assert_equal expected_time.to_s(:db), Time.now.to_s(:db) + end + + assert_operator expected_time.to_s(:db), :<, Time.now.to_s(:db) + end end |