diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 17 |
2 files changed, 15 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index d09d3d844b..e9cdb7fbef 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -403,7 +403,7 @@ module ActionController # Executes a request simulating HEAD HTTP method and set/volley the response def head(action, parameters = nil, session = nil, flash = nil) - process(action, parameters, session, flash, "HEAD") + process(action, "HEAD", parameters, session, flash) end def xml_http_request(request_method, action, parameters = nil, session = nil, flash = nil) @@ -433,7 +433,7 @@ module ActionController check_required_ivars http_method, args = handle_old_process_api(http_method, args) - if args.first.is_a?(String) + if args.first.is_a?(String) && http_method != 'HEAD' @request.env['RAW_POST_DATA'] = args.shift end diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 73b860ac18..34b06df8d8 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -171,22 +171,31 @@ XML assert_equal params.to_query, @response.body end - + def test_document_body_and_params_with_post post :test_params, :id => 1 assert_equal("{\"id\"=>\"1\", \"controller\"=>\"test_test/test\", \"action\"=>\"test_params\"}", @response.body) end - + def test_document_body_with_post post :render_body, "document body" assert_equal "document body", @response.body end - + def test_document_body_with_put put :render_body, "document body" assert_equal "document body", @response.body end + def test_head + head :test_params + assert_equal 200, @response.status + end + + def test_head_params_as_sting + assert_raise(NoMethodError) { head :test_params, "document body", :id => 10 } + end + def test_process_without_flash process :set_flash assert_equal '><', flash['test'] @@ -245,7 +254,7 @@ XML process :test_uri, "GET", :id => 7 assert_equal "/test_test/test/test_uri/7", @response.body end - + def test_process_with_old_api assert_deprecated do process :test_uri, :id => 7 |