aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2011-11-23 23:49:43 +0900
committerkennyj <kennyj@gmail.com>2011-11-24 00:25:34 +0900
commitea70e027b63a1b8bfe4087a4de978ad4eef5575b (patch)
tree4e347f8c65b51733e9df01eb4105c7577b6d7a52 /actionpack
parenta93ee92da2b9ba83e3a3fe0b8d4dd5cac2790f15 (diff)
downloadrails-ea70e027b63a1b8bfe4087a4de978ad4eef5575b.tar.gz
rails-ea70e027b63a1b8bfe4087a4de978ad4eef5575b.tar.bz2
rails-ea70e027b63a1b8bfe4087a4de978ad4eef5575b.zip
Remove unreachable code, and add additional testcases.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/middleware/params_parser.rb7
-rw-r--r--actionpack/test/dispatch/request/json_params_parsing_test.rb12
-rw-r--r--actionpack/test/dispatch/request/xml_params_parsing_test.rb12
3 files changed, 25 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/params_parser.rb b/actionpack/lib/action_dispatch/middleware/params_parser.rb
index d4208ca96e..84e3dd16dd 100644
--- a/actionpack/lib/action_dispatch/middleware/params_parser.rb
+++ b/actionpack/lib/action_dispatch/middleware/params_parser.rb
@@ -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)
diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb
index d854d55173..d481a2df13 100644
--- a/actionpack/test/dispatch/request/json_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb
@@ -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
diff --git a/actionpack/test/dispatch/request/xml_params_parsing_test.rb b/actionpack/test/dispatch/request/xml_params_parsing_test.rb
index 38453dfe48..65a25557b7 100644
--- a/actionpack/test/dispatch/request/xml_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/xml_params_parsing_test.rb
@@ -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>