actionpack 4.1.7 → 4.2.11
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +404 -451
- data/README.rdoc +7 -2
- data/lib/abstract_controller/base.rb +16 -6
- data/lib/abstract_controller/callbacks.rb +28 -51
- data/lib/abstract_controller/helpers.rb +11 -4
- data/lib/abstract_controller/railties/routes_helpers.rb +3 -3
- data/lib/abstract_controller/rendering.rb +7 -1
- data/lib/abstract_controller/url_for.rb +1 -1
- data/lib/action_controller/base.rb +3 -2
- data/lib/action_controller/caching/fragments.rb +7 -1
- data/lib/action_controller/caching.rb +1 -1
- data/lib/action_controller/log_subscriber.rb +26 -26
- data/lib/action_controller/metal/conditional_get.rb +37 -12
- data/lib/action_controller/metal/etag_with_template_digest.rb +50 -0
- data/lib/action_controller/metal/exceptions.rb +1 -1
- data/lib/action_controller/metal/force_ssl.rb +1 -1
- data/lib/action_controller/metal/head.rb +7 -3
- data/lib/action_controller/metal/http_authentication.rb +20 -10
- data/lib/action_controller/metal/instrumentation.rb +8 -5
- data/lib/action_controller/metal/live.rb +57 -6
- data/lib/action_controller/metal/mime_responds.rb +25 -246
- data/lib/action_controller/metal/params_wrapper.rb +5 -5
- data/lib/action_controller/metal/rack_delegation.rb +1 -1
- data/lib/action_controller/metal/redirecting.rb +14 -8
- data/lib/action_controller/metal/renderers.rb +29 -11
- data/lib/action_controller/metal/rendering.rb +2 -6
- data/lib/action_controller/metal/request_forgery_protection.rb +78 -7
- data/lib/action_controller/metal/streaming.rb +1 -1
- data/lib/action_controller/metal/strong_parameters.rb +129 -14
- data/lib/action_controller/metal/url_for.rb +11 -12
- data/lib/action_controller/metal.rb +12 -11
- data/lib/action_controller/model_naming.rb +1 -1
- data/lib/action_controller/railtie.rb +4 -0
- data/lib/action_controller/test_case.rb +119 -75
- data/lib/action_controller.rb +1 -1
- data/lib/action_dispatch/http/cache.rb +5 -4
- data/lib/action_dispatch/http/filter_parameters.rb +2 -2
- data/lib/action_dispatch/http/headers.rb +43 -9
- data/lib/action_dispatch/http/mime_negotiation.rb +10 -3
- data/lib/action_dispatch/http/mime_type.rb +18 -4
- data/lib/action_dispatch/http/parameter_filter.rb +1 -1
- data/lib/action_dispatch/http/parameters.rb +11 -26
- data/lib/action_dispatch/http/request.rb +37 -11
- data/lib/action_dispatch/http/response.rb +74 -23
- data/lib/action_dispatch/http/upload.rb +9 -8
- data/lib/action_dispatch/http/url.rb +89 -70
- data/lib/action_dispatch/journey/formatter.rb +34 -18
- data/lib/action_dispatch/journey/gtg/builder.rb +3 -3
- data/lib/action_dispatch/journey/gtg/simulator.rb +10 -7
- data/lib/action_dispatch/journey/gtg/transition_table.rb +20 -28
- data/lib/action_dispatch/journey/nfa/dot.rb +2 -2
- data/lib/action_dispatch/journey/nfa/simulator.rb +1 -1
- data/lib/action_dispatch/journey/nfa/transition_table.rb +5 -5
- data/lib/action_dispatch/journey/nodes/node.rb +4 -0
- data/lib/action_dispatch/journey/parser.rb +52 -60
- data/lib/action_dispatch/journey/parser.y +11 -10
- data/lib/action_dispatch/journey/path/pattern.rb +16 -19
- data/lib/action_dispatch/journey/route.rb +4 -19
- data/lib/action_dispatch/journey/router/strexp.rb +9 -6
- data/lib/action_dispatch/journey/router/utils.rb +1 -1
- data/lib/action_dispatch/journey/router.rb +53 -77
- data/lib/action_dispatch/journey/routes.rb +4 -0
- data/lib/action_dispatch/journey/scanner.rb +5 -5
- data/lib/action_dispatch/journey/visitors.rb +81 -92
- data/lib/action_dispatch/journey/visualizer/fsm.css +0 -4
- data/lib/action_dispatch/journey/visualizer/index.html.erb +2 -2
- data/lib/action_dispatch/middleware/callbacks.rb +1 -1
- data/lib/action_dispatch/middleware/cookies.rb +34 -34
- data/lib/action_dispatch/middleware/debug_exceptions.rb +15 -4
- data/lib/action_dispatch/middleware/exception_wrapper.rb +50 -18
- data/lib/action_dispatch/middleware/flash.rb +13 -7
- data/lib/action_dispatch/middleware/params_parser.rb +1 -1
- data/lib/action_dispatch/middleware/public_exceptions.rb +12 -3
- data/lib/action_dispatch/middleware/remote_ip.rb +40 -54
- data/lib/action_dispatch/middleware/request_id.rb +1 -1
- data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -1
- data/lib/action_dispatch/middleware/show_exceptions.rb +1 -0
- data/lib/action_dispatch/middleware/ssl.rb +1 -1
- data/lib/action_dispatch/middleware/static.rb +75 -39
- data/lib/action_dispatch/middleware/templates/rescues/_source.erb +21 -19
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +37 -9
- data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +2 -8
- data/lib/action_dispatch/middleware/templates/rescues/{diagnostics.erb → diagnostics.html.erb} +0 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +6 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +4 -0
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +2 -0
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -24
- data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +0 -1
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +120 -64
- data/lib/action_dispatch/railtie.rb +2 -0
- data/lib/action_dispatch/routing/endpoint.rb +10 -0
- data/lib/action_dispatch/routing/inspector.rb +5 -12
- data/lib/action_dispatch/routing/mapper.rb +414 -283
- data/lib/action_dispatch/routing/polymorphic_routes.rb +191 -79
- data/lib/action_dispatch/routing/redirection.rb +10 -12
- data/lib/action_dispatch/routing/route_set.rb +300 -173
- data/lib/action_dispatch/routing/routes_proxy.rb +5 -4
- data/lib/action_dispatch/routing/url_for.rb +17 -5
- data/lib/action_dispatch/testing/assertions/dom.rb +2 -26
- data/lib/action_dispatch/testing/assertions/response.rb +2 -7
- data/lib/action_dispatch/testing/assertions/routing.rb +22 -22
- data/lib/action_dispatch/testing/assertions/selector.rb +2 -429
- data/lib/action_dispatch/testing/assertions/tag.rb +2 -134
- data/lib/action_dispatch/testing/assertions.rb +11 -7
- data/lib/action_dispatch/testing/integration.rb +28 -20
- data/lib/action_dispatch/testing/test_request.rb +1 -1
- data/lib/action_dispatch/testing/test_response.rb +1 -5
- data/lib/action_pack/gem_version.rb +3 -3
- metadata +55 -13
- data/lib/action_controller/metal/responder.rb +0 -297
@@ -23,25 +23,24 @@ module ActionController
|
|
23
23
|
include AbstractController::UrlFor
|
24
24
|
|
25
25
|
def url_options
|
26
|
-
@_url_options ||=
|
26
|
+
@_url_options ||= {
|
27
27
|
:host => request.host,
|
28
28
|
:port => request.optional_port,
|
29
29
|
:protocol => request.protocol,
|
30
|
-
:_recall => request.
|
31
|
-
).freeze
|
30
|
+
:_recall => request.path_parameters
|
31
|
+
}.merge!(super).freeze
|
32
32
|
|
33
|
-
if (same_origin = _routes.equal?(env["action_dispatch.routes"])) ||
|
33
|
+
if (same_origin = _routes.equal?(env["action_dispatch.routes".freeze])) ||
|
34
34
|
(script_name = env["ROUTES_#{_routes.object_id}_SCRIPT_NAME"]) ||
|
35
|
-
(original_script_name = env['ORIGINAL_SCRIPT_NAME'])
|
35
|
+
(original_script_name = env['ORIGINAL_SCRIPT_NAME'.freeze])
|
36
36
|
|
37
|
-
@_url_options.dup
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
options.freeze
|
37
|
+
options = @_url_options.dup
|
38
|
+
if original_script_name
|
39
|
+
options[:original_script_name] = original_script_name
|
40
|
+
else
|
41
|
+
options[:script_name] = same_origin ? request.script_name.dup : script_name
|
44
42
|
end
|
43
|
+
options.freeze
|
45
44
|
else
|
46
45
|
@_url_options
|
47
46
|
end
|
@@ -30,10 +30,8 @@ module ActionController
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def build(action, app=
|
34
|
-
app ||= block
|
33
|
+
def build(action, app = Proc.new)
|
35
34
|
action = action.to_s
|
36
|
-
raise "MiddlewareStack#build requires an app" unless app
|
37
35
|
|
38
36
|
middlewares.reverse.inject(app) do |a, middleware|
|
39
37
|
middleware.valid?(action) ? middleware.build(a) : a
|
@@ -167,7 +165,7 @@ module ActionController
|
|
167
165
|
headers["Location"] = url
|
168
166
|
end
|
169
167
|
|
170
|
-
#
|
168
|
+
# Basic url_for that can be overridden for more robust functionality
|
171
169
|
def url_for(string)
|
172
170
|
string
|
173
171
|
end
|
@@ -175,6 +173,7 @@ module ActionController
|
|
175
173
|
def status
|
176
174
|
@_status
|
177
175
|
end
|
176
|
+
alias :response_code :status # :nodoc:
|
178
177
|
|
179
178
|
def status=(status)
|
180
179
|
@_status = Rack::Utils.status_code(status)
|
@@ -185,6 +184,7 @@ module ActionController
|
|
185
184
|
super
|
186
185
|
end
|
187
186
|
|
187
|
+
# Tests if render or redirect has already happened.
|
188
188
|
def performed?
|
189
189
|
response_body || (response && response.committed?)
|
190
190
|
end
|
@@ -223,18 +223,19 @@ module ActionController
|
|
223
223
|
# Makes the controller a Rack endpoint that runs the action in the given
|
224
224
|
# +env+'s +action_dispatch.request.path_parameters+ key.
|
225
225
|
def self.call(env)
|
226
|
-
|
226
|
+
req = ActionDispatch::Request.new env
|
227
|
+
action(req.path_parameters[:action]).call(env)
|
227
228
|
end
|
228
229
|
|
229
230
|
# Returns a Rack endpoint for the given action name.
|
230
231
|
def self.action(name, klass = ActionDispatch::Request)
|
231
|
-
middleware_stack.
|
232
|
-
|
232
|
+
if middleware_stack.any?
|
233
|
+
middleware_stack.build(name) do |env|
|
234
|
+
new.dispatch(name, klass.new(env))
|
235
|
+
end
|
236
|
+
else
|
237
|
+
lambda { |env| new.dispatch(name, klass.new(env)) }
|
233
238
|
end
|
234
239
|
end
|
235
|
-
|
236
|
-
def _status_code
|
237
|
-
@_status
|
238
|
-
end
|
239
240
|
end
|
240
241
|
end
|
@@ -23,6 +23,10 @@ module ActionController
|
|
23
23
|
options = app.config.action_controller
|
24
24
|
|
25
25
|
ActionController::Parameters.permit_all_parameters = options.delete(:permit_all_parameters) { false }
|
26
|
+
if app.config.action_controller[:always_permitted_parameters]
|
27
|
+
ActionController::Parameters.always_permitted_parameters =
|
28
|
+
app.config.action_controller.delete(:always_permitted_parameters)
|
29
|
+
end
|
26
30
|
ActionController::Parameters.action_on_unpermitted_parameters = options.delete(:action_on_unpermitted_parameters) do
|
27
31
|
(Rails.env.test? || Rails.env.development?) ? :log : false
|
28
32
|
end
|
@@ -2,6 +2,9 @@ require 'rack/session/abstract/id'
|
|
2
2
|
require 'active_support/core_ext/object/to_query'
|
3
3
|
require 'active_support/core_ext/module/anonymous'
|
4
4
|
require 'active_support/core_ext/hash/keys'
|
5
|
+
require 'active_support/deprecation'
|
6
|
+
|
7
|
+
require 'rails-dom-testing'
|
5
8
|
|
6
9
|
module ActionController
|
7
10
|
module TemplateAssertions
|
@@ -12,13 +15,16 @@ module ActionController
|
|
12
15
|
teardown :teardown_subscriptions
|
13
16
|
end
|
14
17
|
|
18
|
+
RENDER_TEMPLATE_INSTANCE_VARIABLES = %w{partials templates layouts files}.freeze
|
19
|
+
|
15
20
|
def setup_subscriptions
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
RENDER_TEMPLATE_INSTANCE_VARIABLES.each do |instance_variable|
|
22
|
+
instance_variable_set("@_#{instance_variable}", Hash.new(0))
|
23
|
+
end
|
24
|
+
|
25
|
+
@_subscribers = []
|
20
26
|
|
21
|
-
ActiveSupport::Notifications.subscribe("render_template.action_view") do |_name, _start, _finish, _id, payload|
|
27
|
+
@_subscribers << ActiveSupport::Notifications.subscribe("render_template.action_view") do |_name, _start, _finish, _id, payload|
|
22
28
|
path = payload[:layout]
|
23
29
|
if path
|
24
30
|
@_layouts[path] += 1
|
@@ -28,42 +34,48 @@ module ActionController
|
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload|
|
32
|
-
|
33
|
-
|
34
|
-
partial = path =~ /^.*\/_[^\/]*$/
|
35
|
-
|
36
|
-
if partial
|
37
|
-
@_partials[path] += 1
|
38
|
-
@_partials[path.split("/").last] += 1
|
39
|
-
end
|
40
|
-
|
41
|
-
@_templates[path] += 1
|
42
|
-
end
|
37
|
+
@_subscribers << ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload|
|
38
|
+
if virtual_path = payload[:virtual_path]
|
39
|
+
partial = virtual_path =~ /^.*\/_[^\/]*$/
|
43
40
|
|
44
|
-
|
45
|
-
|
41
|
+
if partial
|
42
|
+
@_partials[virtual_path] += 1
|
43
|
+
@_partials[virtual_path.split("/").last] += 1
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
@_templates[virtual_path] += 1
|
47
|
+
else
|
48
|
+
path = payload[:identifier]
|
49
|
+
if path
|
50
|
+
@_files[path] += 1
|
51
|
+
@_files[path.split("/").last] += 1
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
57
|
def teardown_subscriptions
|
56
|
-
|
57
|
-
|
58
|
+
return unless defined?(@_subscribers)
|
59
|
+
|
60
|
+
@_subscribers.each do |subscriber|
|
61
|
+
ActiveSupport::Notifications.unsubscribe(subscriber)
|
62
|
+
end
|
58
63
|
end
|
59
64
|
|
60
65
|
def process(*args)
|
61
|
-
|
62
|
-
@_templates = Hash.new(0)
|
63
|
-
@_layouts = Hash.new(0)
|
66
|
+
reset_template_assertion
|
64
67
|
super
|
65
68
|
end
|
66
69
|
|
70
|
+
def reset_template_assertion
|
71
|
+
RENDER_TEMPLATE_INSTANCE_VARIABLES.each do |instance_variable|
|
72
|
+
ivar_name = "@_#{instance_variable}"
|
73
|
+
if instance_variable_defined?(ivar_name)
|
74
|
+
instance_variable_get(ivar_name).clear
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
67
79
|
# Asserts that the request was rendered with the appropriate template file or partials.
|
68
80
|
#
|
69
81
|
# # assert that the "new" view template was rendered
|
@@ -87,6 +99,13 @@ module ActionController
|
|
87
99
|
# # assert that no partials were rendered
|
88
100
|
# assert_template partial: false
|
89
101
|
#
|
102
|
+
# # assert that a file was rendered
|
103
|
+
# assert_template file: "README.rdoc"
|
104
|
+
#
|
105
|
+
# # assert that no file was rendered
|
106
|
+
# assert_template file: nil
|
107
|
+
# assert_template file: false
|
108
|
+
#
|
90
109
|
# In a view test case, you can also assert that specific locals are passed
|
91
110
|
# to partials:
|
92
111
|
#
|
@@ -136,6 +155,8 @@ module ActionController
|
|
136
155
|
|
137
156
|
if options[:file]
|
138
157
|
assert_includes @_files.keys, options[:file]
|
158
|
+
elsif options.key?(:file)
|
159
|
+
assert @_files.blank?, "expected no files but #{@_files.keys} was rendered"
|
139
160
|
end
|
140
161
|
|
141
162
|
if expected_partial = options[:partial]
|
@@ -197,7 +218,7 @@ module ActionController
|
|
197
218
|
value = value.dup
|
198
219
|
end
|
199
220
|
|
200
|
-
if extra_keys.include?(key
|
221
|
+
if extra_keys.include?(key)
|
201
222
|
non_path_parameters[key] = value
|
202
223
|
else
|
203
224
|
if value.is_a?(Array)
|
@@ -206,7 +227,7 @@ module ActionController
|
|
206
227
|
value = value.to_param
|
207
228
|
end
|
208
229
|
|
209
|
-
path_parameters[key
|
230
|
+
path_parameters[key] = value
|
210
231
|
end
|
211
232
|
end
|
212
233
|
|
@@ -231,7 +252,6 @@ module ActionController
|
|
231
252
|
@formats = nil
|
232
253
|
@env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ }
|
233
254
|
@env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ }
|
234
|
-
@symbolized_path_params = nil
|
235
255
|
@method = @request_method = nil
|
236
256
|
@fullpath = @ip = @remote_ip = @protocol = nil
|
237
257
|
@env['action_dispatch.request.query_parameters'] = {}
|
@@ -309,6 +329,10 @@ module ActionController
|
|
309
329
|
clear
|
310
330
|
end
|
311
331
|
|
332
|
+
def fetch(key, *args, &block)
|
333
|
+
@data.fetch(key.to_s, *args, &block)
|
334
|
+
end
|
335
|
+
|
312
336
|
private
|
313
337
|
|
314
338
|
def load!
|
@@ -430,6 +454,7 @@ module ActionController
|
|
430
454
|
extend ActiveSupport::Concern
|
431
455
|
include ActionDispatch::TestProcess
|
432
456
|
include ActiveSupport::Testing::ConstantLookup
|
457
|
+
include Rails::Dom::Testing::Assertions
|
433
458
|
|
434
459
|
attr_reader :response, :request
|
435
460
|
|
@@ -453,7 +478,6 @@ module ActionController
|
|
453
478
|
end
|
454
479
|
|
455
480
|
def controller_class=(new_class)
|
456
|
-
prepare_controller_class(new_class) if new_class
|
457
481
|
self._controller_class = new_class
|
458
482
|
end
|
459
483
|
|
@@ -470,11 +494,6 @@ module ActionController
|
|
470
494
|
Class === constant && constant < ActionController::Metal
|
471
495
|
end
|
472
496
|
end
|
473
|
-
|
474
|
-
def prepare_controller_class(new_class)
|
475
|
-
new_class.send :include, ActionController::TestCase::RaiseActionExceptions
|
476
|
-
end
|
477
|
-
|
478
497
|
end
|
479
498
|
|
480
499
|
# Simulate a GET request with the given parameters.
|
@@ -486,8 +505,8 @@ module ActionController
|
|
486
505
|
# - +session+: A hash of parameters to store in the session. This may be +nil+.
|
487
506
|
# - +flash+: A hash of parameters to store in the flash. This may be +nil+.
|
488
507
|
#
|
489
|
-
# You can also simulate POST, PATCH, PUT, DELETE,
|
490
|
-
# +post+, +patch+, +put+, +delete+,
|
508
|
+
# You can also simulate POST, PATCH, PUT, DELETE, and HEAD requests with
|
509
|
+
# +post+, +patch+, +put+, +delete+, and +head+.
|
491
510
|
#
|
492
511
|
# Note that the request method is not verified. The different methods are
|
493
512
|
# available to make the tests more expressive.
|
@@ -548,6 +567,31 @@ module ActionController
|
|
548
567
|
end
|
549
568
|
end
|
550
569
|
|
570
|
+
# Simulate a HTTP request to +action+ by specifying request method,
|
571
|
+
# parameters and set/volley the response.
|
572
|
+
#
|
573
|
+
# - +action+: The controller action to call.
|
574
|
+
# - +http_method+: Request method used to send the http request. Possible values
|
575
|
+
# are +GET+, +POST+, +PATCH+, +PUT+, +DELETE+, +HEAD+. Defaults to +GET+.
|
576
|
+
# - +parameters+: The HTTP parameters. This may be +nil+, a hash, or a
|
577
|
+
# string that is appropriately encoded (+application/x-www-form-urlencoded+
|
578
|
+
# or +multipart/form-data+).
|
579
|
+
# - +session+: A hash of parameters to store in the session. This may be +nil+.
|
580
|
+
# - +flash+: A hash of parameters to store in the flash. This may be +nil+.
|
581
|
+
#
|
582
|
+
# Example calling +create+ action and sending two params:
|
583
|
+
#
|
584
|
+
# process :create, 'POST', user: { name: 'Gaurish Sharma', email: 'user@example.com' }
|
585
|
+
#
|
586
|
+
# Example sending parameters, +nil+ session and setting a flash message:
|
587
|
+
#
|
588
|
+
# process :view, 'GET', { id: 7 }, nil, { notice: 'This is flash message' }
|
589
|
+
#
|
590
|
+
# To simulate +GET+, +POST+, +PATCH+, +PUT+, +DELETE+ and +HEAD+ requests
|
591
|
+
# prefer using #get, #post, #patch, #put, #delete and #head methods
|
592
|
+
# respectively which will make tests more expressive.
|
593
|
+
#
|
594
|
+
# Note that the request method is not verified.
|
551
595
|
def process(action, http_method = 'GET', *args)
|
552
596
|
check_required_ivars
|
553
597
|
|
@@ -556,16 +600,17 @@ module ActionController
|
|
556
600
|
end
|
557
601
|
|
558
602
|
parameters, session, flash = args
|
603
|
+
parameters ||= {}
|
559
604
|
|
560
605
|
# Ensure that numbers and symbols passed as params are converted to
|
561
606
|
# proper params, as is the case when engaging rack.
|
562
607
|
parameters = paramify_values(parameters) if html_format?(parameters)
|
563
608
|
|
564
609
|
@html_document = nil
|
610
|
+
@html_scanner_document = nil
|
565
611
|
|
566
612
|
unless @controller.respond_to?(:recycle!)
|
567
613
|
@controller.extend(Testing::Functional)
|
568
|
-
@controller.class.class_eval { include Testing }
|
569
614
|
end
|
570
615
|
|
571
616
|
@request.recycle!
|
@@ -574,7 +619,6 @@ module ActionController
|
|
574
619
|
|
575
620
|
@request.env['REQUEST_METHOD'] = http_method
|
576
621
|
|
577
|
-
parameters ||= {}
|
578
622
|
controller_class_name = @controller.class.anonymous? ?
|
579
623
|
"anonymous" :
|
580
624
|
@controller.class.controller_path
|
@@ -602,8 +646,11 @@ module ActionController
|
|
602
646
|
@response.prepare!
|
603
647
|
|
604
648
|
@assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
|
605
|
-
|
606
|
-
|
649
|
+
|
650
|
+
if flash_value = @request.flash.to_session_value
|
651
|
+
@request.session['flash'] = flash_value
|
652
|
+
end
|
653
|
+
|
607
654
|
@response
|
608
655
|
end
|
609
656
|
|
@@ -651,6 +698,11 @@ module ActionController
|
|
651
698
|
end
|
652
699
|
|
653
700
|
private
|
701
|
+
|
702
|
+
def document_root_element
|
703
|
+
html_document.root
|
704
|
+
end
|
705
|
+
|
654
706
|
def check_required_ivars
|
655
707
|
# Sanity check for required instance variables so we can give an
|
656
708
|
# understandable error message.
|
@@ -665,12 +717,32 @@ module ActionController
|
|
665
717
|
unless @request.env["PATH_INFO"]
|
666
718
|
options = @controller.respond_to?(:url_options) ? @controller.__send__(:url_options).merge(parameters) : parameters
|
667
719
|
options.update(
|
668
|
-
:only_path => true,
|
669
720
|
:action => action,
|
670
721
|
:relative_url_root => nil,
|
671
|
-
:_recall => @request.
|
722
|
+
:_recall => @request.path_parameters)
|
723
|
+
|
724
|
+
if route_name = options.delete(:use_route)
|
725
|
+
ActiveSupport::Deprecation.warn <<-MSG.squish
|
726
|
+
Passing the `use_route` option in functional tests are deprecated.
|
727
|
+
Support for this option in the `process` method (and the related
|
728
|
+
`get`, `head`, `post`, `patch`, `put` and `delete` helpers) will
|
729
|
+
be removed in the next version without replacement.
|
730
|
+
|
731
|
+
Functional tests are essentially unit tests for controllers and
|
732
|
+
they should not require knowledge to how the application's routes
|
733
|
+
are configured. Instead, you should explicitly pass the appropiate
|
734
|
+
params to the `process` method.
|
735
|
+
|
736
|
+
Previously the engines guide also contained an incorrect example
|
737
|
+
that recommended using this option to test an engine's controllers
|
738
|
+
within the dummy application. That recommendation was incorrect
|
739
|
+
and has since been corrected. Instead, you should override the
|
740
|
+
`@routes` variable in the test case with `Foo::Engine.routes`. See
|
741
|
+
the updated engines guide for details.
|
742
|
+
MSG
|
743
|
+
end
|
672
744
|
|
673
|
-
url, query_string = @routes.
|
745
|
+
url, query_string = @routes.path_for(options, route_name).split("?", 2)
|
674
746
|
|
675
747
|
@request.env["SCRIPT_NAME"] = @controller.config.relative_url_root
|
676
748
|
@request.env["PATH_INFO"] = url
|
@@ -679,39 +751,11 @@ module ActionController
|
|
679
751
|
end
|
680
752
|
|
681
753
|
def html_format?(parameters)
|
682
|
-
return true unless parameters.
|
754
|
+
return true unless parameters.key?(:format)
|
683
755
|
Mime.fetch(parameters[:format]) { Mime['html'] }.html?
|
684
756
|
end
|
685
757
|
end
|
686
758
|
|
687
|
-
# When the request.remote_addr remains the default for testing, which is 0.0.0.0, the exception is simply raised inline
|
688
|
-
# (skipping the regular exception handling from rescue_action). If the request.remote_addr is anything else, the regular
|
689
|
-
# rescue_action process takes place. This means you can test your rescue_action code by setting remote_addr to something else
|
690
|
-
# than 0.0.0.0.
|
691
|
-
#
|
692
|
-
# The exception is stored in the exception accessor for further inspection.
|
693
|
-
module RaiseActionExceptions
|
694
|
-
def self.included(base) #:nodoc:
|
695
|
-
unless base.method_defined?(:exception) && base.method_defined?(:exception=)
|
696
|
-
base.class_eval do
|
697
|
-
attr_accessor :exception
|
698
|
-
protected :exception, :exception=
|
699
|
-
end
|
700
|
-
end
|
701
|
-
end
|
702
|
-
|
703
|
-
protected
|
704
|
-
def rescue_action_without_handler(e)
|
705
|
-
self.exception = e
|
706
|
-
|
707
|
-
if request.remote_addr == "0.0.0.0"
|
708
|
-
raise(e)
|
709
|
-
else
|
710
|
-
super(e)
|
711
|
-
end
|
712
|
-
end
|
713
|
-
end
|
714
|
-
|
715
759
|
include Behavior
|
716
760
|
end
|
717
761
|
end
|