aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 14a96169dd..cc7a55b2ee 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -171,6 +171,7 @@ uses_tzinfo 'TimeWithZoneTest' do
assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @dt.in_time_zone('Hawaii').inspect
assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @t.in_time_zone('UTC').inspect
assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @dt.in_time_zone('UTC').inspect
+ assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @t.in_time_zone(-9.hours).inspect
end
end
end
@@ -208,6 +209,7 @@ uses_tzinfo 'TimeWithZoneTest' do
assert_equal 'Sat, 01 Jan 2000 00:00:00 HST -10:00', @dt.change_time_zone('Hawaii').inspect
assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @t.change_time_zone('UTC').inspect
assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @dt.change_time_zone('UTC').inspect
+ assert_equal 'Sat, 01 Jan 2000 00:00:00 AKST -09:00', @t.change_time_zone(-9.hours).inspect
end
end
end
@@ -228,6 +230,28 @@ uses_tzinfo 'TimeWithZoneTest' do
assert_equal TimeZone['Alaska'], Time.zone
end
+ def test_time_zone_getter_and_setter
+ Time.zone = TimeZone['Alaska']
+ assert_equal TimeZone['Alaska'], Time.zone
+ Time.zone = 'Alaska'
+ assert_equal TimeZone['Alaska'], Time.zone
+ Time.zone = -9.hours
+ assert_equal TimeZone['Alaska'], Time.zone
+ Time.zone = nil
+ assert_equal nil, Time.zone
+ end
+
+ def test_time_zone_getter_and_setter_with_zone_default
+ Time.zone_default = TimeZone['Alaska']
+ assert_equal TimeZone['Alaska'], Time.zone
+ Time.zone = TimeZone['Hawaii']
+ assert_equal TimeZone['Hawaii'], Time.zone
+ Time.zone = nil
+ assert_equal TimeZone['Alaska'], Time.zone
+ ensure
+ Time.zone_default = nil
+ end
+
def test_time_zone_setter_is_thread_safe
Time.use_zone 'Paris' do
t1 = Thread.new { Time.zone = 'Alaska' }