diff options
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
-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 |