Permalink
Browse files

Fix json params parsing regression for non-object JSON content.

Fixes #8845.
  • Loading branch information...
dylanahsmith committed Jan 9, 2013
1 parent 8a7fad8 commit bae92681be97191edda90990e08b5275d187107f
View
@@ -1,5 +1,9 @@
## Rails 4.0.0 (unreleased) ##
+* Fixed json params parsing regression for non-object JSON content.
+
+ *Dylan Smith*
+
* Extract `ActionDispatch::PerformanceTest` into https://github.com/rails/rails-perftest
You can add the gem to your Gemfile to keep using performance tests.
@@ -50,9 +50,9 @@ def parse_formatted_parameters(env)
data = request.deep_munge(Hash.from_xml(request.body.read) || {})
data.with_indifferent_access
when :json
- data = request.deep_munge ActiveSupport::JSON.decode(request.body)
+ data = ActiveSupport::JSON.decode(request.body)
data = {:_json => data} unless data.is_a?(Hash)
- data.with_indifferent_access
+ request.deep_munge(data).with_indifferent_access
else
false
end
@@ -122,6 +122,13 @@ def teardown
)
end
+ test "parses json with non-object JSON content" do
+ assert_parses(
+ {"user" => {"_json" => "string content" }, "_json" => "string content" },
+ "\"string content\"", { 'CONTENT_TYPE' => 'application/json' }
+ )
+ end
+
private
def assert_parses(expected, actual, headers = {})
with_test_routing(UsersController) do

0 comments on commit bae9268

Please sign in to comment.