aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_with_zone_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-07-10 15:41:46 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2013-07-10 15:49:09 +0100
commit4d733d2dd4acd7fa8b8d5886f4ec9cac8321f96f (patch)
tree6cb23c4b4859724d49a1640f37680e1dac2ceb69 /activesupport/test/core_ext/time_with_zone_test.rb
parentdabcfc4914d6f1828189e90db79ce651249a5a19 (diff)
downloadrails-4d733d2dd4acd7fa8b8d5886f4ec9cac8321f96f.tar.gz
rails-4d733d2dd4acd7fa8b8d5886f4ec9cac8321f96f.tar.bz2
rails-4d733d2dd4acd7fa8b8d5886f4ec9cac8321f96f.zip
Add failing test for #9562
Rails 4.0.0 fails when trying to encode an ActiveSupport::TimeWithZone that wraps a DateTime instance. This is fixed on master so add a test to prevent regression. (cherry picked from commit ad01b8da354268cebfae1519c28d19d75576ccb1)
Diffstat (limited to 'activesupport/test/core_ext/time_with_zone_test.rb')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb5
1 files changed, 5 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 ddcfcc491f..fab3d8ac38 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -80,6 +80,11 @@ class TimeWithZoneTest < ActiveSupport::TestCase
ActiveSupport.use_standard_json_time_format = old
end
+ def test_to_json_when_wrapping_a_date_time
+ twz = ActiveSupport::TimeWithZone.new(DateTime.civil(2000), @time_zone)
+ assert_equal '"1999-12-31T19:00:00.000-05:00"', ActiveSupport::JSON.encode(twz)
+ end
+
def test_nsec
local = Time.local(2011,6,7,23,59,59,Rational(999999999, 1000))
with_zone = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Hawaii"], local)