Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #14923 from gaurish/document-testcase-process

Document ActionController::TestCase::Behavior#process

[ci skip]
  • Loading branch information...
commit 52d9746119f07bcb2182f39e539add9b20199ce6 2 parents 242bcac + 4a43769
@senny senny authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 actionpack/lib/action_controller/test_case.rb
View
27 actionpack/lib/action_controller/test_case.rb
@@ -550,6 +550,33 @@ def paramify_values(hash_or_array_or_value)
end
end
+ # Simulate a HTTP request to +action+ by specifying request method,
+ # parameters and set/volley the response.
+ #
+ # - +action+: The controller action to call.
+ # - +http_method+: request method used to send http request.
+ # possible values GET, POST, HEAD, PUT, DELETE, PATCH. defaults to GET.
+ # - +parameters+: The HTTP parameters.
+ # This may be +nil+, a hash, or a string that is appropriately encoded
+ # (+application/x-www-form-urlencoded+ or +multipart/form-data+).
+ # - +session+: A hash of parameters to store in the session.
+ # This may be +nil+.
+ # - +flash+: A hash of parameters to store in the flash.
+ # This may be +nil+.
+ #
+ # example: calling +create+ action & sending two params
+ #
+ # process :create, 'POST', user: { name: 'Gaurish Sharma', email: 'user@example.com' }
+ #
+ # another example with parameters, +nil+ session & flash message
+ #
+ # process :view, 'GET', { id: 7 }, nil, { message: 'This is flash message' }
+ #
+ # To simulate +GET+, +POST+, +PATCH+, +PUT+,
+ # +DELETE+ and +HEAD+ requests prefer using #get, #post, #patch, #put,
+ # #delete and #head respectively which will make tests more expressive.
+ #
+ # Note that the request method is not verified.
def process(action, http_method = 'GET', *args)
check_required_ivars
Please sign in to comment.
Something went wrong with that request. Please try again.