mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #3735 from kennyj/fix_3728
Fix #3728 Remove unreachable code, and add additional testcases.
This commit is contained in:
@@ -54,12 +54,7 @@ module ActionDispatch
|
||||
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)
|
||||
|
||||
@@ -45,6 +45,18 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest
|
||||
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
|
||||
|
||||
@@ -67,6 +67,18 @@ class XmlParamsParsingTest < ActionDispatch::IntegrationTest
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user