Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove unreachable code, and add additional testcases.

  • Loading branch information...
commit ea70e027b63a1b8bfe4087a4de978ad4eef5575b 1 parent a93ee92
@kennyj kennyj authored
View
7 actionpack/lib/action_dispatch/middleware/params_parser.rb
@@ -54,12 +54,7 @@ def parse_formatted_parameters(env)
rescue Exception => e # YAML, XML or Ruby code block errors
logger.debug "Error occurred while parsing request parameters.\nContents:\n\n#{request.raw_post}"
- raise
- { "body" => request.raw_post,
- "content_type" => request.content_mime_type,
- "content_length" => request.content_length,
- "exception" => "#{e.message} (#{e.class})",
- "backtrace" => e.backtrace }
+ raise e
end
def content_type_from_legacy_post_data_format_header(env)
View
12 actionpack/test/dispatch/request/json_params_parsing_test.rb
@@ -45,6 +45,18 @@ def teardown
end
end
+ test "occurring a parse error if parsing unsuccessful" do
+ with_test_routing do
+ begin
+ $stderr = StringIO.new # suppress the log
+ json = "[\"person]\": {\"name\": \"David\"}}"
+ assert_raise(MultiJson::DecodeError) { post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => false} }
+ ensure
+ $stderr = STDERR
+ end
+ end
+ end
+
private
def assert_parses(expected, actual, headers = {})
with_test_routing do
View
12 actionpack/test/dispatch/request/xml_params_parsing_test.rb
@@ -67,6 +67,18 @@ def call(env)
end
end
+ test "occurring a parse error if parsing unsuccessful" do
+ with_test_routing do
+ begin
+ $stderr = StringIO.new # suppress the log
+ xml = "<person><name>David</name></pineapple>"
+ assert_raise(REXML::ParseException) { post "/parse", xml, default_headers.merge('action_dispatch.show_exceptions' => false) }
+ ensure
+ $stderr = STDERR
+ end
+ end
+ end
+
test "parses multiple files" do
xml = <<-end_body
<person>

0 comments on commit ea70e02

Please sign in to comment.
Something went wrong with that request. Please try again.