diff options
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index caaebc537a..e958cfecdf 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -550,6 +550,33 @@ module ActionController 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 |