Skip to content

Commit 4d733d2

Browse files
committed
Add failing test for rails#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 ad01b8d)
1 parent dabcfc4 commit 4d733d2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

activesupport/test/core_ext/time_with_zone_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ def test_to_json_with_use_standard_json_time_format_config_set_to_true
8080
ActiveSupport.use_standard_json_time_format = old
8181
end
8282

83+
def test_to_json_when_wrapping_a_date_time
84+
twz = ActiveSupport::TimeWithZone.new(DateTime.civil(2000), @time_zone)
85+
assert_equal '"1999-12-31T19:00:00.000-05:00"', ActiveSupport::JSON.encode(twz)
86+
end
87+
8388
def test_nsec
8489
local = Time.local(2011,6,7,23,59,59,Rational(999999999, 1000))
8590
with_zone = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Hawaii"], local)

0 commit comments

Comments
 (0)