diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-09-24 17:41:55 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-09-24 17:41:55 +0000 |
commit | 2a60093fa35312e83aeaa3185ea0fc20f3ee50be (patch) | |
tree | f6070ca6ae02060b2892807f1cf171a240aa92de /activesupport/test/json | |
parent | 911ea2f26f0a8d240b8a76a41d7a4ce978c72b12 (diff) | |
download | rails-2a60093fa35312e83aeaa3185ea0fc20f3ee50be.tar.gz rails-2a60093fa35312e83aeaa3185ea0fc20f3ee50be.tar.bz2 rails-2a60093fa35312e83aeaa3185ea0fc20f3ee50be.zip |
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
Diffstat (limited to 'activesupport/test/json')
-rw-r--r-- | activesupport/test/json/decoding_test.rb | 12 |
1 files changed, 9 insertions, 3 deletions
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 |