diff options
Diffstat (limited to 'actionpack/test/dispatch/request_test.rb')
-rw-r--r-- | actionpack/test/dispatch/request_test.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index a2b9571660..e2964f9071 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -550,15 +550,30 @@ class RequestTest < ActiveSupport::TestCase test "parameters still accessible after rack parse error" do mock_rack_env = { "QUERY_STRING" => "x[y]=1&x[y][][w]=2", "rack.input" => "foo" } request = nil - begin - request = stub_request(mock_rack_env) - request.parameters - rescue ActionController::BadRequest + request = stub_request(mock_rack_env) + + assert_raises(ActionController::BadRequest) do # rack will raise a TypeError when parsing this query string + request.parameters end + assert_equal({}, request.parameters) end + test "we have access to the original exception" do + mock_rack_env = { "QUERY_STRING" => "x[y]=1&x[y][][w]=2", "rack.input" => "foo" } + request = nil + request = stub_request(mock_rack_env) + + e = assert_raises(ActionController::BadRequest) do + # rack will raise a TypeError when parsing this query string + request.parameters + end + + assert e.original_exception + assert_equal e.original_exception.backtrace, e.backtrace + end + test "formats with accept header" do request = stub_request 'HTTP_ACCEPT' => 'text/html' request.expects(:parameters).at_least_once.returns({}) |