From 370bcd1a017816422db2fdb410366752d60d72c8 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 21 Jan 2011 14:09:59 -0800 Subject: use ! " " YAML string literal syntax rather than removing both quotes --- activesupport/test/json/decoding_test.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'activesupport/test/json/decoding_test.rb') diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index d2e3efaa6b..a0beb97537 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -57,9 +57,7 @@ class TestJSONDecoding < ActiveSupport::TestCase ActiveSupport.parse_json_times = true silence_warnings do ActiveSupport::JSON.with_backend backend do - assert_nothing_raised do - assert_equal expected, ActiveSupport::JSON.decode(json) - end + assert_equal expected, ActiveSupport::JSON.decode(json) end end end -- cgit v1.2.3 From 68e3fb81090ba67575e513407fc2463dba3b002b Mon Sep 17 00:00:00 2001 From: Maxime RETY Date: Mon, 14 Jun 2010 16:05:49 +0200 Subject: Fix JSON decoding of newline character with Yaml backend [#3479 state:resolved] Signed-off-by: Santiago Pastorino --- activesupport/test/json/decoding_test.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activesupport/test/json/decoding_test.rb') diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index a0beb97537..613c7531d9 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -41,7 +41,11 @@ class TestJSONDecoding < ActiveSupport::TestCase [{'d' => Date.new(1970, 1, 1), 's' => ' escape'},{'d' => Date.new(1970, 1, 1), 's' => ' escape'}], %q([{"d":"1970-01-01","s":"http:\/\/example.com"},{"d":"1970-01-01","s":"http:\/\/example.com"}]) => [{'d' => Date.new(1970, 1, 1), 's' => 'http://example.com'}, - {'d' => Date.new(1970, 1, 1), 's' => 'http://example.com'}] + {'d' => Date.new(1970, 1, 1), 's' => 'http://example.com'}], + # tests escaping of "\n" char with Yaml backend + %q("\n") => "\n", + %q("\u000a") => "\n", + %q({"a":"Line1\u000aLine2"}) => {"a"=>"Line1\nLine2"} } # load the default JSON backend -- cgit v1.2.3 From 434aa095607669f3b95343e874064d7c74bf921c Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 2 Feb 2011 20:52:38 -0200 Subject: Fix tests providing valid JSON --- activesupport/test/json/decoding_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/test/json/decoding_test.rb') diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 613c7531d9..436861baad 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -43,8 +43,8 @@ class TestJSONDecoding < ActiveSupport::TestCase [{'d' => Date.new(1970, 1, 1), 's' => 'http://example.com'}, {'d' => Date.new(1970, 1, 1), 's' => 'http://example.com'}], # tests escaping of "\n" char with Yaml backend - %q("\n") => "\n", - %q("\u000a") => "\n", + %q({"a":"\n"}) => {"a"=>"\n"}, + %q({"a":"\u000a"}) => {"a"=>"\n"}, %q({"a":"Line1\u000aLine2"}) => {"a"=>"Line1\nLine2"} } -- cgit v1.2.3 From b17d8d727fb510ad8b6eb4302984d290dc2e53b0 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 11 Feb 2011 16:47:25 +0100 Subject: Fixes an issue when decoding a json string which looks like a date but is invalid. This DateTime parse error is now caught and the original string is instead passed back [#6286 state:resolved] Signed-off-by: Santiago Pastorino --- activesupport/test/json/decoding_test.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/test/json/decoding_test.rb') diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 436861baad..77f24f0de3 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -19,6 +19,8 @@ class TestJSONDecoding < ActiveSupport::TestCase %({"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"}, + # invalid date + %({"a": "1089-10-40"}) => {'a' => "1089-10-40"}, # needs to be *exact* %({"a": " 2007-01-01 01:12:34 Z "}) => {'a' => " 2007-01-01 01:12:34 Z "}, %({"a": "2007-01-01 : it's your birthday"}) => {'a' => "2007-01-01 : it's your birthday"}, -- cgit v1.2.3 From e8c870726a67a27965b2a5333a5ecf450d4f458f Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Sat, 12 Feb 2011 16:29:17 +0100 Subject: Updated the json date regex to recognize xmlschema formatted date times during json decoding. [#3031 state:resolved] Signed-off-by: Santiago Pastorino and Emilio Tagua --- activesupport/test/json/decoding_test.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activesupport/test/json/decoding_test.rb') diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 77f24f0de3..24d9f88c09 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -21,6 +21,10 @@ class TestJSONDecoding < ActiveSupport::TestCase %({"a": "2007-01-01 01:12:34"}) => {'a' => "2007-01-01 01:12:34"}, # invalid date %({"a": "1089-10-40"}) => {'a' => "1089-10-40"}, + # xmlschema date notation + %({"a": "2009-08-10T19:01:02Z"}) => {'a' => Time.utc(2009, 8, 10, 19, 1, 2)}, + %({"a": "2009-08-10T19:01:02+02:00"}) => {'a' => Time.utc(2009, 8, 10, 17, 1, 2)}, + %({"a": "2009-08-10T19:01:02-05:00"}) => {'a' => Time.utc(2009, 8, 11, 00, 1, 2)}, # needs to be *exact* %({"a": " 2007-01-01 01:12:34 Z "}) => {'a' => " 2007-01-01 01:12:34 Z "}, %({"a": "2007-01-01 : it's your birthday"}) => {'a' => "2007-01-01 : it's your birthday"}, -- cgit v1.2.3