Permalink
Browse files

Merge pull request #8888 from dylanahsmith/3-2-parse-non-object-json-…

…params

3-2-stable: Fix JSON params parsing regression for non-object JSON content.
  • Loading branch information...
2 parents d564ee0 + 7003b36 commit 3211eb17b999523d19d7e5e4431e0f1ac25a740f @jeremy jeremy committed Jan 11, 2013
View
@@ -1,5 +1,9 @@
## Rails 3.2.12 (unreleased) ##
+* Fixed JSON params parsing regression for non-object JSON content.
+
+ *Dylan Smith*
+
* Prevent unnecessary asset compilation when using `javascript_include_tag` on
files with non-standard extensions.
@@ -44,10 +44,10 @@ def parse_formatted_parameters(env)
when :yaml
YAML.load(request.raw_post)
when :json
- data = request.deep_munge ActiveSupport::JSON.decode(request.body)
+ data = ActiveSupport::JSON.decode(request.body)
request.body.rewind if request.body.respond_to?(:rewind)
data = {:_json => data} unless data.is_a?(Hash)
- data.with_indifferent_access
+ request.deep_munge(data).with_indifferent_access
else
false
end
@@ -120,6 +120,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 3211eb1

Please sign in to comment.