diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-10-26 03:22:02 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-10-26 03:22:02 +0000 |
commit | 34c125d774ed817d45bb11a5173f989ca16cc514 (patch) | |
tree | 804c6c0bb20e94323cd36c04869051616a6c7a58 /activesupport/test/json/decoding_test.rb | |
parent | 8b2a6014a2971159c2169704ee5d3402f8d8d1a3 (diff) | |
download | rails-34c125d774ed817d45bb11a5173f989ca16cc514.tar.gz rails-34c125d774ed817d45bb11a5173f989ca16cc514.tar.bz2 rails-34c125d774ed817d45bb11a5173f989ca16cc514.zip |
Fix JSON encoding/decoding bugs dealing with /'s. Closes #9990 [Rick, theamazingrando]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8026 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/json/decoding_test.rb')
-rw-r--r-- | activesupport/test/json/decoding_test.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index f0b0da32c8..93560fb5a2 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -2,10 +2,10 @@ require File.dirname(__FILE__) + '/../abstract_unit' class TestJSONDecoding < Test::Unit::TestCase TESTS = { - %({"returnTo":{"/categories":"/"}}) => {"returnTo" => {"/categories" => "/"}}, - %({returnTo:{"/categories":"/"}}) => {"returnTo" => {"/categories" => "/"}}, - %({"return\\"To\\":":{"/categories":"/"}}) => {"return\"To\":" => {"/categories" => "/"}}, - %({"returnTo":{"/categories":1}}) => {"returnTo" => {"/categories" => 1}}, + %q({"returnTo":{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}}, + %q({returnTo:{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}}, + %q({"return\\"To\\":":{"\/categories":"\/"}}) => {"return\"To\":" => {"/categories" => "/"}}, + %q({"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"}, @@ -23,11 +23,12 @@ class TestJSONDecoding < Test::Unit::TestCase %("\\"") => "\"", %(null) => nil, %(true) => true, - %(false) => false + %(false) => false, + %q("http:\/\/test.host\/posts\/1") => "http://test.host/posts/1" } - def test_json_decoding - TESTS.each do |json, expected| + TESTS.each do |json, expected| + define_method :"test_json_decoding_#{json}" do assert_nothing_raised do assert_equal expected, ActiveSupport::JSON.decode(json) end @@ -37,4 +38,4 @@ class TestJSONDecoding < Test::Unit::TestCase def test_failed_json_decoding assert_raises(ActiveSupport::JSON::ParseError) { ActiveSupport::JSON.decode(%({: 1})) } end -end
\ No newline at end of file +end |