From ce65a05c5b027175c3c541055081f82c8bfc36bf Mon Sep 17 00:00:00 2001 From: Luca Guidi Date: Wed, 27 Aug 2008 11:25:20 +0200 Subject: 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] --- activesupport/test/core_ext/time_ext_test.rb | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'activesupport/test') 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 -- cgit v1.2.3