Skip to content

Commit

Permalink
Add failing test for #9562
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
pixeltrix committed Jul 10, 2013
1 parent dabcfc4 commit 4d733d2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions activesupport/test/core_ext/time_with_zone_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def test_to_json_with_use_standard_json_time_format_config_set_to_true
ActiveSupport.use_standard_json_time_format = old ActiveSupport.use_standard_json_time_format = old
end 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 def test_nsec
local = Time.local(2011,6,7,23,59,59,Rational(999999999, 1000)) local = Time.local(2011,6,7,23,59,59,Rational(999999999, 1000))
with_zone = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Hawaii"], local) with_zone = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Hawaii"], local)
Expand Down

0 comments on commit 4d733d2

Please sign in to comment.