diff options
author | Zuhao Wan <wanzuhao@gmail.com> | 2014-06-18 19:46:04 +0800 |
---|---|---|
committer | Zuhao Wan <wanzuhao@gmail.com> | 2014-06-18 19:46:04 +0800 |
commit | 9c492885d178b1a3d0de2f710a8a276db3d867b2 (patch) | |
tree | 1bcf8d640a8d302e1df5a56587f0f7e58b3922c6 /activesupport/test/core_ext/date_time_ext_test.rb | |
parent | e2f232aba15937a4b9d14bd91e0392c6d55be58d (diff) | |
download | rails-9c492885d178b1a3d0de2f710a8a276db3d867b2.tar.gz rails-9c492885d178b1a3d0de2f710a8a276db3d867b2.tar.bz2 rails-9c492885d178b1a3d0de2f710a8a276db3d867b2.zip |
Extract out with_env_tz helper method.
It’s used at so many places that extracting it out into a helper file
is worth doing.
Diffstat (limited to 'activesupport/test/core_ext/date_time_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/date_time_ext_test.rb | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index 224172e39f..2c08b46791 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -1,6 +1,7 @@ require 'abstract_unit' require 'active_support/time' require 'core_ext/date_and_time_behavior' +require 'time_zone_test_helpers' class DateTimeExtCalculationsTest < ActiveSupport::TestCase def date_time_init(year,month,day,hour,minute,second,*args) @@ -8,6 +9,7 @@ class DateTimeExtCalculationsTest < ActiveSupport::TestCase end include DateAndTimeBehavior + include TimeZoneTestHelpers def test_to_s datetime = DateTime.new(2005, 2, 21, 14, 30, 0, 0) @@ -352,12 +354,4 @@ class DateTimeExtCalculationsTest < ActiveSupport::TestCase assert_equal 0, DateTime.civil(2000).nsec assert_equal 500000000, DateTime.civil(2000, 1, 1, 0, 0, Rational(1,2)).nsec 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 |