diff options
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-rw-r--r-- | activesupport/test/core_ext/time_with_zone_test.rb | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index e828e62f9b..8a868b9c62 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -21,8 +21,14 @@ uses_tzinfo 'TimeWithZoneTest' do def test_time_zone assert_equal @time_zone, @twz.time_zone end - + def test_in_time_zone + Time.use_zone 'Alaska' do + assert_equal ActiveSupport::TimeWithZone.new(@utc, TimeZone['Alaska']), @twz.in_time_zone + end + end + + def test_in_time_zone_with_argument assert_equal ActiveSupport::TimeWithZone.new(@utc, TimeZone['Alaska']), @twz.in_time_zone('Alaska') end @@ -30,12 +36,6 @@ uses_tzinfo 'TimeWithZoneTest' do assert_equal @twz.object_id, @twz.in_time_zone(TimeZone['Eastern Time (US & Canada)']).object_id end - def test_in_current_time_zone - Time.use_zone 'Alaska' do - assert_equal ActiveSupport::TimeWithZone.new(@utc, TimeZone['Alaska']), @twz.in_current_time_zone - end - end - def test_utc? assert_equal false, @twz.utc? assert_equal true, ActiveSupport::TimeWithZone.new(Time.utc(2000), TimeZone['UTC']).utc? @@ -298,9 +298,26 @@ uses_tzinfo 'TimeWithZoneTest' do def teardown Time.zone = nil end - + def test_in_time_zone silence_warnings do # silence warnings raised by tzinfo gem + Time.use_zone 'Alaska' do + assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @t.in_time_zone.inspect + assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @dt.in_time_zone.inspect + end + Time.use_zone 'Hawaii' do + assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @t.in_time_zone.inspect + assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @dt.in_time_zone.inspect + end + Time.use_zone nil do + assert_equal @t, @t.in_time_zone + assert_equal @dt, @dt.in_time_zone + end + end + end + + def test_in_time_zone_with_argument + silence_warnings do # silence warnings raised by tzinfo gem Time.use_zone 'Eastern Time (US & Canada)' do # Time.zone will not affect #in_time_zone(zone) assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @t.in_time_zone('Alaska').inspect assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @dt.in_time_zone('Alaska').inspect @@ -321,23 +338,6 @@ uses_tzinfo 'TimeWithZoneTest' do end end end - - def test_in_current_time_zone - silence_warnings do # silence warnings raised by tzinfo gem - Time.use_zone 'Alaska' do - assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @t.in_current_time_zone.inspect - assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @dt.in_current_time_zone.inspect - end - Time.use_zone 'Hawaii' do - assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @t.in_current_time_zone.inspect - assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @dt.in_current_time_zone.inspect - end - Time.use_zone nil do - assert_equal @t, @t.in_current_time_zone - assert_equal @dt, @dt.in_current_time_zone - end - end - end def test_use_zone Time.zone = 'Alaska' |