diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-12 10:13:14 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-12 10:13:14 -0700 |
commit | 0fbb797e5f667443e49f3c3a2b370eb00dc48951 (patch) | |
tree | a52d6b24e0a2cd16e78ef63a45e138a4ce7ee878 /activesupport/test/json/decoding_test.rb | |
parent | 4bdf929579cf80713518cc12b4610dd3ae7a9adf (diff) | |
parent | 52fb1a9565a2c1d163efa95f3d1a42247a4cc074 (diff) | |
download | rails-0fbb797e5f667443e49f3c3a2b370eb00dc48951.tar.gz rails-0fbb797e5f667443e49f3c3a2b370eb00dc48951.tar.bz2 rails-0fbb797e5f667443e49f3c3a2b370eb00dc48951.zip |
Merge pull request #12207 from chancancode/fix_json_load
Enabled quirks mode on JSON.parse, fixes broken test in af9caae
Diffstat (limited to 'activesupport/test/json/decoding_test.rb')
-rw-r--r-- | activesupport/test/json/decoding_test.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 3ec9b06d6a..e9780b36e4 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -59,7 +59,16 @@ class TestJSONDecoding < ActiveSupport::TestCase %q({"a":"\n"}) => {"a"=>"\n"}, %q({"a":"\u000a"}) => {"a"=>"\n"}, %q({"a":"Line1\u000aLine2"}) => {"a"=>"Line1\nLine2"}, - %q({"json_class":"TestJSONDecoding::Foo"}) => {"json_class"=>"TestJSONDecoding::Foo"} + # prevent json unmarshalling + %q({"json_class":"TestJSONDecoding::Foo"}) => {"json_class"=>"TestJSONDecoding::Foo"}, + # json "fragments" - these are invalid JSON, but ActionPack relies on this + %q("a string") => "a string", + %q(1.1) => 1.1, + %q(1) => 1, + %q(-1) => -1, + %q(true) => true, + %q(false) => false, + %q(null) => nil } TESTS.each_with_index do |(json, expected), index| @@ -83,7 +92,10 @@ class TestJSONDecoding < ActiveSupport::TestCase end def test_failed_json_decoding + assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%(undefined)) } + assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%({a: 1})) } assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%({: 1})) } + assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%()) } end def test_cannot_force_json_unmarshalling |