Class: ActionController::TestRequest
- Inherits:
-
AbstractRequest
- Object
- AbstractRequest
- ActionController::TestRequest
- Defined in:
- lib/action_controller/test_process.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#env ⇒ Object
Returns the value of attribute env.
-
#host ⇒ Object
Returns the value of attribute host.
-
#path ⇒ Object
Returns the value of attribute path.
-
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
-
#request_parameters ⇒ Object
Returns the value of attribute request_parameters.
-
#session ⇒ Object
Returns the value of attribute session.
-
#session_options ⇒ Object
Returns the value of attribute session_options.
Instance Method Summary collapse
- #action=(action_name) ⇒ Object
- #assign_parameters(controller_path, action, parameters) ⇒ Object
-
#initialize(query_parameters = nil, request_parameters = nil, session = nil) ⇒ TestRequest
constructor
A new instance of TestRequest.
- #port=(number) ⇒ Object
- #recycle! ⇒ Object
- #remote_addr ⇒ Object
- #remote_addr=(addr) ⇒ Object
- #request_uri ⇒ Object
- #request_uri=(uri) ⇒ Object
- #reset_session ⇒ Object
-
#set_REQUEST_URI(value) ⇒ Object
Used to check AbstractRequest’s request_uri functionality.
Methods inherited from AbstractRequest
#delete?, #domain, #formatted_post?, #get?, #head?, #host_with_port, #method, #parameters, #path_parameters, #path_parameters=, #port, #port_string, #post?, #post_format, #protocol, #put?, #raw_post, #relative_url_root, #remote_ip, #server_software, #ssl?, #standard_port, #subdomains, #symbolized_path_parameters, #xml_http_request?, #xml_post?, #yaml_post?
Constructor Details
#initialize(query_parameters = nil, request_parameters = nil, session = nil) ⇒ TestRequest
Returns a new instance of TestRequest.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/action_controller/test_process.rb', line 30 def initialize(query_parameters = nil, request_parameters = nil, session = nil) @query_parameters = query_parameters || {} @request_parameters = request_parameters || {} @session = session || TestSession.new initialize_containers initialize_default_values super() end |
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies.
26 27 28 |
# File 'lib/action_controller/test_process.rb', line 26 def @cookies end |
#env ⇒ Object
Returns the value of attribute env.
27 28 29 |
# File 'lib/action_controller/test_process.rb', line 27 def env @env end |
#host ⇒ Object
Returns the value of attribute host.
28 29 30 |
# File 'lib/action_controller/test_process.rb', line 28 def host @host end |
#path ⇒ Object
Returns the value of attribute path.
27 28 29 |
# File 'lib/action_controller/test_process.rb', line 27 def path @path end |
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
27 28 29 |
# File 'lib/action_controller/test_process.rb', line 27 def query_parameters @query_parameters end |
#request_parameters ⇒ Object
Returns the value of attribute request_parameters.
27 28 29 |
# File 'lib/action_controller/test_process.rb', line 27 def request_parameters @request_parameters end |
#session ⇒ Object
Returns the value of attribute session.
27 28 29 |
# File 'lib/action_controller/test_process.rb', line 27 def session @session end |
#session_options ⇒ Object
Returns the value of attribute session_options.
26 27 28 |
# File 'lib/action_controller/test_process.rb', line 26 def @session_options end |
Instance Method Details
#action=(action_name) ⇒ Object
50 51 52 53 |
# File 'lib/action_controller/test_process.rb', line 50 def action=(action_name) @query_parameters.update({ "action" => action_name }) @parameters = nil end |
#assign_parameters(controller_path, action, parameters) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/action_controller/test_process.rb', line 84 def assign_parameters(controller_path, action, parameters) parameters = parameters.symbolize_keys.merge(:controller => controller_path, :action => action) extra_keys = ActionController::Routing::Routes.extra_keys(parameters) non_path_parameters = get? ? query_parameters : request_parameters parameters.each do |key, value| if value.is_a? Fixnum value = value.to_s elsif value.is_a? Array value = ActionController::Routing::PathComponent::Result.new(value) end if extra_keys.include?(key.to_sym) non_path_parameters[key] = value else path_parameters[key.to_s] = value end end end |
#port=(number) ⇒ Object
45 46 47 48 |
# File 'lib/action_controller/test_process.rb', line 45 def port=(number) @env["SERVER_PORT"] = number.to_i @port_as_int = nil end |
#recycle! ⇒ Object
103 104 105 106 107 |
# File 'lib/action_controller/test_process.rb', line 103 def recycle! self.request_parameters = {} self.query_parameters = {} self.path_parameters = {} end |
#remote_addr ⇒ Object
72 73 74 |
# File 'lib/action_controller/test_process.rb', line 72 def remote_addr @env['REMOTE_ADDR'] end |
#remote_addr=(addr) ⇒ Object
68 69 70 |
# File 'lib/action_controller/test_process.rb', line 68 def remote_addr=(addr) @env['REMOTE_ADDR'] = addr end |
#request_uri ⇒ Object
76 77 78 |
# File 'lib/action_controller/test_process.rb', line 76 def request_uri @request_uri || super() end |
#request_uri=(uri) ⇒ Object
63 64 65 66 |
# File 'lib/action_controller/test_process.rb', line 63 def request_uri=(uri) @request_uri = uri @path = uri.split("?").first end |
#reset_session ⇒ Object
41 42 43 |
# File 'lib/action_controller/test_process.rb', line 41 def reset_session @session = {} end |
#set_REQUEST_URI(value) ⇒ Object
Used to check AbstractRequest’s request_uri functionality. Disables the use of @path and @request_uri so superclass can handle those.
57 58 59 60 61 |
# File 'lib/action_controller/test_process.rb', line 57 def set_REQUEST_URI(value) @env["REQUEST_URI"] = value @request_uri = nil @path = nil end |