From 7004434ad85901215e1cb4367b2b8b1e7f9063c7 Mon Sep 17 00:00:00 2001 From: Diego Carrion Date: Wed, 9 Mar 2011 20:27:29 -0300 Subject: test json decoding with time parsing disabled with all backends and respect ActiveSupport.parse_json_times when converting to yaml Signed-off-by: Santiago Pastorino --- activesupport/test/json/decoding_test.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 24d9f88c09..6b890c7d46 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -72,13 +72,11 @@ class TestJSONDecoding < ActiveSupport::TestCase end end end - end - if backends.include?("JSONGem") - test "json decodes time json with time parsing disabled" do + test "json decodes time json with time parsing disabled with the #{backend} backend" do ActiveSupport.parse_json_times = false expected = {"a" => "2007-01-01 01:12:34 Z"} - ActiveSupport::JSON.with_backend "JSONGem" do + ActiveSupport::JSON.with_backend backend do assert_equal expected, ActiveSupport::JSON.decode(%({"a": "2007-01-01 01:12:34 Z"})) end end -- cgit v1.2.3 From a1edbf720620c672566a1681572c3845452ca51a Mon Sep 17 00:00:00 2001 From: Diego Carrion Date: Wed, 9 Mar 2011 21:45:45 -0300 Subject: parse dates to yaml in json arrays Signed-off-by: Santiago Pastorino --- activesupport/test/json/decoding_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 6b890c7d46..88cf97de7e 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -17,6 +17,8 @@ class TestJSONDecoding < ActiveSupport::TestCase %({"matzue": "松江", "asakusa": "浅草"}) => {"matzue" => "松江", "asakusa" => "浅草"}, %({"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)}, + %(["2007-01-01 01:12:34 Z"]) => [Time.utc(2007, 1, 1, 1, 12, 34)], + %(["2007-01-01 01:12:34 Z", "2007-01-01 01:12:35 Z"]) => [Time.utc(2007, 1, 1, 1, 12, 34), Time.utc(2007, 1, 1, 1, 12, 35)], # no time zone %({"a": "2007-01-01 01:12:34"}) => {'a' => "2007-01-01 01:12:34"}, # invalid date -- cgit v1.2.3