Class: ActionDispatch::TestRequest
- Inherits:
-
Request
show all
- Defined in:
- actionpack/lib/action_dispatch/testing/test_request.rb
Constant Summary
collapse
- DEFAULT_ENV =
Rack::MockRequest.env_for('/')
Constants inherited
from Request
Request::ENV_METHODS, Request::HTTP_METHODS, Request::HTTP_METHOD_LOOKUP, Request::LOCALHOST, Request::RFC2518, Request::RFC2616, Request::RFC3253, Request::RFC3648, Request::RFC3744, Request::RFC5323, Request::RFC5789, Request::TRUSTED_PROXIES
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Request
#GET, #POST, #authorization, #body, #body_stream, #content_length, #cookie_jar, #delete?, #flash, #forgery_whitelisted?, #form_data?, #fullpath, #get?, #head?, #headers, #ip, #key?, #local?, #media_type, #method, #method_symbol, #post?, #put?, #raw_post, #remote_ip, #request_method, #request_method_symbol, #reset_session, #server_software, #session=, #session_options=, #xml_http_request?
Methods included from Http::URL
#domain, extract_domain, extract_subdomain, extract_subdomains, #host, #host_with_port, #optional_port, #port, #port_string, #protocol, #raw_host_with_port, #server_port, #standard_port, #standard_port?, #subdomain, #subdomains, #url, url_for
#filtered_env, #filtered_parameters, #filtered_path
#append_features, extended, #included
#parameters, #path_parameters, #path_parameters=, #symbolized_path_parameters
#accepts, #content_mime_type, #content_type, #format, #format=, #formats, #negotiate_mime
#etag_matches?, #fresh?, #if_modified_since, #if_none_match, #not_modified?
Constructor Details
#initialize(env = {}) ⇒ TestRequest
Returns a new instance of TestRequest.
13
14
15
16
17
18
19
20
21
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 13
def initialize(env = {})
env = Rails.application.env_config.merge(env) if defined?(Rails.application)
super(DEFAULT_ENV.merge(env))
@cookies = nil
self.host = 'test.host'
self.remote_addr = '0.0.0.0'
self.user_agent = 'Rails Testing'
end
|
Class Method Details
.new(env = {}) ⇒ Object
9
10
11
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 9
def self.new(env = {})
super
end
|
Instance Method Details
#accept=(mime_types) ⇒ Object
69
70
71
72
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 69
def accept=(mime_types)
@env.delete('action_dispatch.request.accepts')
@env['HTTP_ACCEPT'] = Array(mime_types).collect { |mime_type| mime_type.to_s }.join(",")
end
|
#action=(action_name) ⇒ Object
49
50
51
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 49
def action=(action_name)
path_parameters["action"] = action_name.to_s
end
|
74
75
76
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 74
def cookies
@cookies ||= super
end
|
23
24
25
26
27
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 23
def env
write_cookies!
delete_nil_values!
super
end
|
#host=(host) ⇒ Object
33
34
35
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 33
def host=(host)
@env['HTTP_HOST'] = host
end
|
#if_modified_since=(last_modified) ⇒ Object
53
54
55
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 53
def if_modified_since=(last_modified)
@env['HTTP_IF_MODIFIED_SINCE'] = last_modified
end
|
#if_none_match=(etag) ⇒ Object
57
58
59
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 57
def if_none_match=(etag)
@env['HTTP_IF_NONE_MATCH'] = etag
end
|
#path=(path) ⇒ Object
45
46
47
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 45
def path=(path)
@env['PATH_INFO'] = path
end
|
#port=(number) ⇒ Object
37
38
39
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 37
def port=(number)
@env['SERVER_PORT'] = number.to_i
end
|
#remote_addr=(addr) ⇒ Object
61
62
63
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 61
def remote_addr=(addr)
@env['REMOTE_ADDR'] = addr
end
|
#request_method=(method) ⇒ Object
29
30
31
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 29
def request_method=(method)
@env['REQUEST_METHOD'] = method.to_s.upcase
end
|
#request_uri=(uri) ⇒ Object
41
42
43
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 41
def request_uri=(uri)
@env['REQUEST_URI'] = uri
end
|
#user_agent=(user_agent) ⇒ Object
65
66
67
|
# File 'actionpack/lib/action_dispatch/testing/test_request.rb', line 65
def user_agent=(user_agent)
@env['HTTP_USER_AGENT'] = user_agent
end
|