From 2a60093fa35312e83aeaa3185ea0fc20f3ee50be Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Mon, 24 Sep 2007 17:41:55 +0000 Subject: Decode json strings as Dates/Times if they're using a YAML-compatible format. Closes #9614 [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7613 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/json/decoding_test.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 01796d5e99..f0b0da32c8 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -8,8 +8,14 @@ class TestJSONDecoding < Test::Unit::TestCase %({"returnTo":{"/categories":1}}) => {"returnTo" => {"/categories" => 1}}, %({"returnTo":[1,"a"]}) => {"returnTo" => [1, "a"]}, %({"returnTo":[1,"\\"a\\",", "b"]}) => {"returnTo" => [1, "\"a\",", "b"]}, - %({a: "'", "b": "5,000"}) => {"a" => "'", "b" => "5,000"}, - %({a: "a's, b's and c's", "b": "5,000"}) => {"a" => "a's, b's and c's", "b" => "5,000"}, + %({a: "'", "b": "5,000"}) => {"a" => "'", "b" => "5,000"}, + %({a: "a's, b's and c's", "b": "5,000"}) => {"a" => "a's, b's and c's", "b" => "5,000"}, + %({a: "2007-01-01"}) => {'a' => Date.new(2007, 1, 1)}, + %({a: "2007-01-01 01:12:34 Z"}) => {'a' => Time.utc(2007, 1, 1, 1, 12, 34)}, + # no time zone + %({a: "2007-01-01 01:12:34"}) => {'a' => "2007-01-01 01:12:34"}, + # needs to be *exact* + %({a: " 2007-01-01 01:12:34 Z "}) => {'a' => " 2007-01-01 01:12:34 Z "}, %([]) => [], %({}) => {}, %(1) => 1, @@ -31,4 +37,4 @@ class TestJSONDecoding < Test::Unit::TestCase def test_failed_json_decoding assert_raises(ActiveSupport::JSON::ParseError) { ActiveSupport::JSON.decode(%({: 1})) } end -end +end \ No newline at end of file -- cgit v1.2.3