diff options
author | Luca Guidi <guidi.luca@gmail.com> | 2008-08-27 11:25:20 +0200 |
---|---|---|
committer | gbuesing <gbuesing@gmail.com> | 2008-08-27 08:57:36 -0500 |
commit | ce65a05c5b027175c3c541055081f82c8bfc36bf (patch) | |
tree | 007ffc3c93c7f7a0ed8f273f7980539397b2145e /activesupport/test/core_ext | |
parent | b7cd4ded9350fff5edee2298dc04a55e6b285233 (diff) | |
download | rails-ce65a05c5b027175c3c541055081f82c8bfc36bf.tar.gz rails-ce65a05c5b027175c3c541055081f82c8bfc36bf.tar.bz2 rails-ce65a05c5b027175c3c541055081f82c8bfc36bf.zip |
Fix Ruby's Time marshaling bug in pre-1.9 versions of Ruby: utc instances are now correctly unmarshaled with a utc zone instead of the system local zone [#900 state:resolved]
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/time_ext_test.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 8740497b3d..4749950f25 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -625,3 +625,37 @@ class TimeExtCalculationsTest < Test::Unit::TestCase old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') end end + +class TimeExtMarshalingTest < Test::Unit::TestCase + def test_marshaling_with_utc_instance + t = Time.utc(2000) + marshaled = Marshal.dump t + unmarshaled = Marshal.load marshaled + assert_equal t, unmarshaled + assert_equal t.zone, unmarshaled.zone + end + + def test_marshaling_with_local_instance + t = Time.local(2000) + marshaled = Marshal.dump t + unmarshaled = Marshal.load marshaled + assert_equal t, unmarshaled + assert_equal t.zone, unmarshaled.zone + end + + def test_marshaling_with_frozen_utc_instance + t = Time.utc(2000).freeze + marshaled = Marshal.dump t + unmarshaled = Marshal.load marshaled + assert_equal t, unmarshaled + assert_equal t.zone, unmarshaled.zone + end + + def test_marshaling_with_frozen_local_instance + t = Time.local(2000).freeze + marshaled = Marshal.dump t + unmarshaled = Marshal.load marshaled + assert_equal t, unmarshaled + assert_equal t.zone, unmarshaled.zone + end +end |