aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request/json_params_parsing_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/dispatch/request/json_params_parsing_test.rb')
-rw-r--r--actionpack/test/dispatch/request/json_params_parsing_test.rb28
1 files changed, 24 insertions, 4 deletions
diff --git a/actionpack/test/dispatch/request/json_params_parsing_test.rb b/actionpack/test/dispatch/request/json_params_parsing_test.rb
index a3dde72c4e..db6cf7b330 100644
--- a/actionpack/test/dispatch/request/json_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/json_params_parsing_test.rb
@@ -30,16 +30,36 @@ class JsonParamsParsingTest < ActionController::IntegrationTest
)
end
+ test "logs error if parsing unsuccessful" do
+ with_test_routing do
+ begin
+ $stderr = StringIO.new
+ json = "[\"person]\": {\"name\": \"David\"}}"
+ post "/parse", json, {'CONTENT_TYPE' => 'application/json'}
+ assert_response :error
+ $stderr.rewind && err = $stderr.read
+ assert err =~ /Error occurred while parsing request parameters/
+ ensure
+ $stderr = STDERR
+ end
+ end
+ end
+
private
def assert_parses(expected, actual, headers = {})
+ with_test_routing do
+ post "/parse", actual, headers
+ assert_response :ok
+ assert_equal(expected, TestController.last_request_parameters)
+ end
+ end
+
+ def with_test_routing
with_routing do |set|
set.draw do |map|
map.connect ':action', :controller => "json_params_parsing_test/test"
end
-
- post "/parse", actual, headers
- assert_response :ok
- assert_equal(expected, TestController.last_request_parameters)
+ yield
end
end
end