aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-02-10 18:45:55 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-02-10 18:45:55 +0000
commitdb4fc6f206f83d8981e006c80f08bfd4bff02e87 (patch)
treee044ae9fdbca5c236c541b005e2401763c0ad126 /activesupport/test/core_ext
parent521714a39d2f74f6a7e617db68f8fafc93a425a0 (diff)
downloadrails-db4fc6f206f83d8981e006c80f08bfd4bff02e87.tar.gz
rails-db4fc6f206f83d8981e006c80f08bfd4bff02e87.tar.bz2
rails-db4fc6f206f83d8981e006c80f08bfd4bff02e87.zip
Time#in_time_zone handles Time.local instances correctly
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8849 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb17
1 files changed, 17 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 3f0ec0720b..14a96169dd 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -174,6 +174,15 @@ uses_tzinfo 'TimeWithZoneTest' do
end
end
end
+
+ def test_in_time_zone_with_time_local_instance
+ silence_warnings do # silence warnings raised by tzinfo gem
+ with_env_tz 'US/Eastern' do
+ time = Time.local(1999, 12, 31, 19) # == Time.utc(2000)
+ assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', time.in_time_zone('Alaska').inspect
+ end
+ end
+ end
def test_in_current_time_zone
Time.use_zone 'Alaska' do
@@ -228,5 +237,13 @@ uses_tzinfo 'TimeWithZoneTest' do
assert_equal TimeZone['Hawaii'], t2[:time_zone]
end
end
+
+ protected
+ def with_env_tz(new_tz = 'US/Eastern')
+ old_tz, ENV['TZ'] = ENV['TZ'], new_tz
+ yield
+ ensure
+ old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
+ end
end
end