aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_with_zone_test.rb
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-02-10 19:02:30 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-02-10 19:02:30 +0000
commitb9be374ddd2142ca53da3c235e35ccbb70c66842 (patch)
tree4a1ca7fd3a93903795a71a8201e2c44d8a108695 /activesupport/test/core_ext/time_with_zone_test.rb
parentdb4fc6f206f83d8981e006c80f08bfd4bff02e87 (diff)
downloadrails-b9be374ddd2142ca53da3c235e35ccbb70c66842.tar.gz
rails-b9be374ddd2142ca53da3c235e35ccbb70c66842.tar.bz2
rails-b9be374ddd2142ca53da3c235e35ccbb70c66842.zip
Time#zone=, #in_time_zone and #change_time_zone accept a Duration
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8850 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-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' }