actionpack 7.1.5.1 → 7.2.0.beta1
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 +4 -4
- data/CHANGELOG.md +61 -642
- data/lib/abstract_controller/asset_paths.rb +2 -0
- data/lib/abstract_controller/base.rb +102 -98
- data/lib/abstract_controller/caching/fragments.rb +50 -53
- data/lib/abstract_controller/caching.rb +2 -0
- data/lib/abstract_controller/callbacks.rb +66 -64
- data/lib/abstract_controller/collector.rb +6 -6
- data/lib/abstract_controller/deprecator.rb +2 -0
- data/lib/abstract_controller/error.rb +2 -0
- data/lib/abstract_controller/helpers.rb +70 -85
- data/lib/abstract_controller/logger.rb +2 -0
- data/lib/abstract_controller/railties/routes_helpers.rb +2 -0
- data/lib/abstract_controller/rendering.rb +13 -12
- data/lib/abstract_controller/translation.rb +12 -13
- data/lib/abstract_controller/url_for.rb +8 -6
- data/lib/abstract_controller.rb +2 -0
- data/lib/action_controller/api/api_rendering.rb +2 -0
- data/lib/action_controller/api.rb +74 -72
- data/lib/action_controller/base.rb +155 -117
- data/lib/action_controller/caching.rb +15 -12
- data/lib/action_controller/deprecator.rb +2 -0
- data/lib/action_controller/form_builder.rb +20 -17
- data/lib/action_controller/log_subscriber.rb +3 -1
- data/lib/action_controller/metal/allow_browser.rb +119 -0
- data/lib/action_controller/metal/basic_implicit_render.rb +2 -0
- data/lib/action_controller/metal/conditional_get.rb +188 -174
- data/lib/action_controller/metal/content_security_policy.rb +25 -24
- data/lib/action_controller/metal/cookies.rb +4 -2
- data/lib/action_controller/metal/data_streaming.rb +64 -55
- data/lib/action_controller/metal/default_headers.rb +5 -3
- data/lib/action_controller/metal/etag_with_flash.rb +3 -1
- data/lib/action_controller/metal/etag_with_template_digest.rb +17 -15
- data/lib/action_controller/metal/exceptions.rb +11 -9
- data/lib/action_controller/metal/flash.rb +12 -10
- data/lib/action_controller/metal/head.rb +12 -10
- data/lib/action_controller/metal/helpers.rb +63 -55
- data/lib/action_controller/metal/http_authentication.rb +214 -203
- data/lib/action_controller/metal/implicit_render.rb +17 -15
- data/lib/action_controller/metal/instrumentation.rb +15 -12
- data/lib/action_controller/metal/live.rb +113 -107
- data/lib/action_controller/metal/logging.rb +6 -4
- data/lib/action_controller/metal/mime_responds.rb +151 -142
- data/lib/action_controller/metal/parameter_encoding.rb +34 -32
- data/lib/action_controller/metal/params_wrapper.rb +57 -59
- data/lib/action_controller/metal/permissions_policy.rb +13 -12
- data/lib/action_controller/metal/rate_limiting.rb +62 -0
- data/lib/action_controller/metal/redirecting.rb +108 -82
- data/lib/action_controller/metal/renderers.rb +50 -49
- data/lib/action_controller/metal/rendering.rb +103 -75
- data/lib/action_controller/metal/request_forgery_protection.rb +162 -133
- data/lib/action_controller/metal/rescue.rb +11 -9
- data/lib/action_controller/metal/streaming.rb +138 -136
- data/lib/action_controller/metal/strong_parameters.rb +483 -478
- data/lib/action_controller/metal/testing.rb +2 -0
- data/lib/action_controller/metal/url_for.rb +17 -15
- data/lib/action_controller/metal.rb +58 -57
- data/lib/action_controller/railtie.rb +3 -0
- data/lib/action_controller/railties/helpers.rb +2 -0
- data/lib/action_controller/renderer.rb +42 -36
- data/lib/action_controller/template_assertions.rb +4 -2
- data/lib/action_controller/test_case.rb +146 -126
- data/lib/action_controller.rb +5 -1
- data/lib/action_dispatch/constants.rb +2 -0
- data/lib/action_dispatch/deprecator.rb +2 -0
- data/lib/action_dispatch/http/cache.rb +27 -26
- data/lib/action_dispatch/http/content_disposition.rb +2 -0
- data/lib/action_dispatch/http/content_security_policy.rb +48 -59
- data/lib/action_dispatch/http/filter_parameters.rb +13 -14
- data/lib/action_dispatch/http/filter_redirect.rb +15 -1
- data/lib/action_dispatch/http/headers.rb +22 -22
- data/lib/action_dispatch/http/mime_negotiation.rb +30 -41
- data/lib/action_dispatch/http/mime_type.rb +25 -21
- data/lib/action_dispatch/http/mime_types.rb +2 -0
- data/lib/action_dispatch/http/parameters.rb +11 -9
- data/lib/action_dispatch/http/permissions_policy.rb +26 -36
- data/lib/action_dispatch/http/rack_cache.rb +2 -0
- data/lib/action_dispatch/http/request.rb +75 -95
- data/lib/action_dispatch/http/response.rb +61 -61
- data/lib/action_dispatch/http/upload.rb +18 -16
- data/lib/action_dispatch/http/url.rb +75 -73
- data/lib/action_dispatch/journey/formatter.rb +13 -6
- data/lib/action_dispatch/journey/gtg/builder.rb +4 -3
- data/lib/action_dispatch/journey/gtg/simulator.rb +2 -0
- data/lib/action_dispatch/journey/gtg/transition_table.rb +10 -8
- data/lib/action_dispatch/journey/nfa/dot.rb +2 -0
- data/lib/action_dispatch/journey/nodes/node.rb +6 -5
- data/lib/action_dispatch/journey/parser.rb +4 -3
- data/lib/action_dispatch/journey/parser_extras.rb +2 -0
- data/lib/action_dispatch/journey/path/pattern.rb +4 -1
- data/lib/action_dispatch/journey/route.rb +9 -7
- data/lib/action_dispatch/journey/router/utils.rb +16 -15
- data/lib/action_dispatch/journey/router.rb +4 -2
- data/lib/action_dispatch/journey/routes.rb +4 -2
- data/lib/action_dispatch/journey/scanner.rb +4 -2
- data/lib/action_dispatch/journey/visitors.rb +2 -0
- data/lib/action_dispatch/journey.rb +2 -0
- data/lib/action_dispatch/log_subscriber.rb +2 -0
- data/lib/action_dispatch/middleware/actionable_exceptions.rb +2 -0
- data/lib/action_dispatch/middleware/assume_ssl.rb +8 -5
- data/lib/action_dispatch/middleware/callbacks.rb +3 -1
- data/lib/action_dispatch/middleware/cookies.rb +119 -104
- data/lib/action_dispatch/middleware/debug_exceptions.rb +13 -5
- data/lib/action_dispatch/middleware/debug_locks.rb +15 -13
- data/lib/action_dispatch/middleware/debug_view.rb +2 -0
- data/lib/action_dispatch/middleware/exception_wrapper.rb +6 -11
- data/lib/action_dispatch/middleware/executor.rb +2 -0
- data/lib/action_dispatch/middleware/flash.rb +63 -51
- data/lib/action_dispatch/middleware/host_authorization.rb +17 -15
- data/lib/action_dispatch/middleware/public_exceptions.rb +8 -6
- data/lib/action_dispatch/middleware/reloader.rb +5 -3
- data/lib/action_dispatch/middleware/remote_ip.rb +77 -72
- data/lib/action_dispatch/middleware/request_id.rb +14 -9
- data/lib/action_dispatch/middleware/server_timing.rb +4 -2
- data/lib/action_dispatch/middleware/session/abstract_store.rb +2 -0
- data/lib/action_dispatch/middleware/session/cache_store.rb +13 -8
- data/lib/action_dispatch/middleware/session/cookie_store.rb +27 -26
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -3
- data/lib/action_dispatch/middleware/show_exceptions.rb +16 -16
- data/lib/action_dispatch/middleware/ssl.rb +43 -40
- data/lib/action_dispatch/middleware/stack.rb +11 -10
- data/lib/action_dispatch/middleware/static.rb +33 -31
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +1 -1
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +1 -1
- data/lib/action_dispatch/railtie.rb +2 -3
- data/lib/action_dispatch/request/session.rb +23 -21
- data/lib/action_dispatch/request/utils.rb +2 -0
- data/lib/action_dispatch/routing/endpoint.rb +2 -0
- data/lib/action_dispatch/routing/inspector.rb +6 -4
- data/lib/action_dispatch/routing/mapper.rb +623 -625
- data/lib/action_dispatch/routing/polymorphic_routes.rb +69 -62
- data/lib/action_dispatch/routing/redirection.rb +37 -32
- data/lib/action_dispatch/routing/route_set.rb +60 -46
- data/lib/action_dispatch/routing/routes_proxy.rb +6 -4
- data/lib/action_dispatch/routing/url_for.rb +130 -125
- data/lib/action_dispatch/routing.rb +150 -148
- data/lib/action_dispatch/system_test_case.rb +91 -81
- data/lib/action_dispatch/system_testing/browser.rb +4 -2
- data/lib/action_dispatch/system_testing/driver.rb +2 -0
- data/lib/action_dispatch/system_testing/server.rb +2 -0
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +32 -21
- data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +2 -0
- data/lib/action_dispatch/testing/assertion_response.rb +8 -6
- data/lib/action_dispatch/testing/assertions/response.rb +26 -23
- data/lib/action_dispatch/testing/assertions/routing.rb +153 -84
- data/lib/action_dispatch/testing/assertions.rb +2 -0
- data/lib/action_dispatch/testing/integration.rb +223 -222
- data/lib/action_dispatch/testing/request_encoder.rb +2 -0
- data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +35 -0
- data/lib/action_dispatch/testing/test_process.rb +12 -8
- data/lib/action_dispatch/testing/test_request.rb +3 -1
- data/lib/action_dispatch/testing/test_response.rb +27 -26
- data/lib/action_dispatch.rb +22 -32
- data/lib/action_pack/gem_version.rb +6 -4
- data/lib/action_pack/version.rb +3 -1
- data/lib/action_pack.rb +17 -16
- metadata +33 -16
@@ -1,27 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
module ActionController
|
4
|
-
#
|
6
|
+
# # Action Controller UrlFor
|
5
7
|
#
|
6
|
-
# Includes
|
7
|
-
# the
|
8
|
+
# Includes `url_for` into the host class. The class has to provide a `RouteSet`
|
9
|
+
# by implementing the `_routes` method. Otherwise, an exception will be raised.
|
8
10
|
#
|
9
|
-
# In addition to AbstractController::UrlFor, this module accesses the HTTP layer
|
10
|
-
# URL options like the
|
11
|
-
# to implement
|
12
|
-
# returns an ActionDispatch::Request instance.
|
11
|
+
# In addition to AbstractController::UrlFor, this module accesses the HTTP layer
|
12
|
+
# to define URL options like the `host`. In order to do so, this module requires
|
13
|
+
# the host class to implement `env` which needs to be Rack-compatible, and
|
14
|
+
# `request` which returns an ActionDispatch::Request instance.
|
13
15
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
16
|
+
# class RootUrl
|
17
|
+
# include ActionController::UrlFor
|
18
|
+
# include Rails.application.routes.url_helpers
|
17
19
|
#
|
18
|
-
#
|
20
|
+
# delegate :env, :request, to: :controller
|
19
21
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
22
|
+
# def initialize(controller)
|
23
|
+
# @controller = controller
|
24
|
+
# @url = root_path # named route from the application.
|
25
|
+
# end
|
23
26
|
# end
|
24
|
-
# end
|
25
27
|
module UrlFor
|
26
28
|
extend ActiveSupport::Concern
|
27
29
|
|
@@ -1,17 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
require "active_support/core_ext/array/extract_options"
|
4
6
|
require "action_dispatch/middleware/stack"
|
5
7
|
|
6
8
|
module ActionController
|
7
|
-
#
|
9
|
+
# # Action Controller MiddlewareStack
|
8
10
|
#
|
9
|
-
# Extend ActionDispatch middleware stack to make it aware of options
|
10
|
-
#
|
11
|
+
# Extend ActionDispatch middleware stack to make it aware of options allowing
|
12
|
+
# the following syntax in controllers:
|
11
13
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
14
|
+
# class PostsController < ApplicationController
|
15
|
+
# use AuthenticationMiddleware, except: [:index, :show]
|
16
|
+
# end
|
15
17
|
#
|
16
18
|
class MiddlewareStack < ActionDispatch::MiddlewareStack # :nodoc:
|
17
19
|
class Middleware < ActionDispatch::MiddlewareStack::Middleware # :nodoc:
|
@@ -60,73 +62,71 @@ module ActionController
|
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
|
-
#
|
65
|
+
# # Action Controller Metal
|
64
66
|
#
|
65
|
-
#
|
67
|
+
# `ActionController::Metal` is the simplest possible controller, providing a
|
66
68
|
# valid Rack interface without the additional niceties provided by
|
67
69
|
# ActionController::Base.
|
68
70
|
#
|
69
71
|
# A sample metal controller might look like this:
|
70
72
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
73
|
+
# class HelloController < ActionController::Metal
|
74
|
+
# def index
|
75
|
+
# self.response_body = "Hello World!"
|
76
|
+
# end
|
74
77
|
# end
|
75
|
-
# end
|
76
78
|
#
|
77
|
-
# And then to route requests to your metal controller, you would add
|
78
|
-
#
|
79
|
+
# And then to route requests to your metal controller, you would add something
|
80
|
+
# like this to `config/routes.rb`:
|
79
81
|
#
|
80
|
-
#
|
82
|
+
# get 'hello', to: HelloController.action(:index)
|
81
83
|
#
|
82
|
-
# The
|
83
|
-
#
|
84
|
+
# The `action` method returns a valid Rack application for the Rails router to
|
85
|
+
# dispatch to.
|
84
86
|
#
|
85
|
-
#
|
87
|
+
# ## Rendering Helpers
|
86
88
|
#
|
87
|
-
#
|
89
|
+
# `ActionController::Metal` by default provides no utilities for rendering
|
88
90
|
# views, partials, or other responses aside from explicitly calling of
|
89
|
-
#
|
90
|
-
#
|
91
|
-
# can do the following:
|
91
|
+
# `response_body=`, `content_type=`, and `status=`. To add the render helpers
|
92
|
+
# you're used to having in a normal controller, you can do the following:
|
92
93
|
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
94
|
+
# class HelloController < ActionController::Metal
|
95
|
+
# include AbstractController::Rendering
|
96
|
+
# include ActionView::Layouts
|
97
|
+
# append_view_path "#{Rails.root}/app/views"
|
97
98
|
#
|
98
|
-
#
|
99
|
-
#
|
99
|
+
# def index
|
100
|
+
# render "hello/index"
|
101
|
+
# end
|
100
102
|
# end
|
101
|
-
# end
|
102
103
|
#
|
103
|
-
#
|
104
|
+
# ## Redirection Helpers
|
104
105
|
#
|
105
106
|
# To add redirection helpers to your metal controller, do the following:
|
106
107
|
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
108
|
+
# class HelloController < ActionController::Metal
|
109
|
+
# include ActionController::Redirecting
|
110
|
+
# include Rails.application.routes.url_helpers
|
110
111
|
#
|
111
|
-
#
|
112
|
-
#
|
112
|
+
# def index
|
113
|
+
# redirect_to root_url
|
114
|
+
# end
|
113
115
|
# end
|
114
|
-
# end
|
115
|
-
#
|
116
|
-
# == Other \Helpers
|
117
116
|
#
|
118
|
-
#
|
119
|
-
# other features you can bring into your metal controller.
|
117
|
+
# ## Other Helpers
|
120
118
|
#
|
119
|
+
# You can refer to the modules included in ActionController::Base to see other
|
120
|
+
# features you can bring into your metal controller.
|
121
121
|
class Metal < AbstractController::Base
|
122
122
|
abstract!
|
123
123
|
|
124
|
-
# Returns the last part of the controller's name, underscored, without the
|
125
|
-
#
|
126
|
-
# Namespaces are left out, so
|
124
|
+
# Returns the last part of the controller's name, underscored, without the
|
125
|
+
# ending `Controller`. For instance, `PostsController` returns `posts`.
|
126
|
+
# Namespaces are left out, so `Admin::PostsController` returns `posts` as well.
|
127
127
|
#
|
128
|
-
#
|
129
|
-
# *
|
128
|
+
# #### Returns
|
129
|
+
# * `string`
|
130
130
|
def self.controller_name
|
131
131
|
@controller_name ||= (name.demodulize.delete_suffix("Controller").underscore unless anonymous?)
|
132
132
|
end
|
@@ -172,7 +172,7 @@ module ActionController
|
|
172
172
|
##
|
173
173
|
# The ActionDispatch::Request::Session instance for the current request.
|
174
174
|
# See further details in the
|
175
|
-
#
|
175
|
+
# [Active Controller Session guide](https://guides.rubyonrails.org/action_controller_overview.html#session).
|
176
176
|
delegate :session, to: "@_request"
|
177
177
|
|
178
178
|
##
|
@@ -201,7 +201,7 @@ module ActionController
|
|
201
201
|
|
202
202
|
alias :response_code :status # :nodoc:
|
203
203
|
|
204
|
-
# Basic
|
204
|
+
# Basic url_for that can be overridden for more robust functionality.
|
205
205
|
def url_for(string)
|
206
206
|
string
|
207
207
|
end
|
@@ -238,7 +238,8 @@ module ActionController
|
|
238
238
|
@_response = response
|
239
239
|
end
|
240
240
|
|
241
|
-
# Assign the response and mark it as committed. No further processing will
|
241
|
+
# Assign the response and mark it as committed. No further processing will
|
242
|
+
# occur.
|
242
243
|
def response=(response)
|
243
244
|
set_response!(response)
|
244
245
|
|
@@ -271,15 +272,15 @@ module ActionController
|
|
271
272
|
|
272
273
|
# The middleware stack used by this controller.
|
273
274
|
#
|
274
|
-
# By default uses a variation of ActionDispatch::MiddlewareStack which
|
275
|
-
#
|
275
|
+
# By default uses a variation of ActionDispatch::MiddlewareStack which allows
|
276
|
+
# for the following syntax:
|
276
277
|
#
|
277
|
-
#
|
278
|
-
#
|
279
|
-
#
|
278
|
+
# class PostsController < ApplicationController
|
279
|
+
# use AuthenticationMiddleware, except: [:index, :show]
|
280
|
+
# end
|
280
281
|
#
|
281
|
-
# Read more about
|
282
|
-
#
|
282
|
+
# Read more about [Rails middleware stack]
|
283
|
+
# (https://guides.rubyonrails.org/rails_on_rack.html#action-dispatcher-middleware-stack)
|
283
284
|
# in the guides.
|
284
285
|
def self.middleware
|
285
286
|
middleware_stack
|
@@ -300,8 +301,8 @@ module ActionController
|
|
300
301
|
end
|
301
302
|
end
|
302
303
|
|
303
|
-
# Direct dispatch to the controller. Instantiates the controller, then
|
304
|
-
#
|
304
|
+
# Direct dispatch to the controller. Instantiates the controller, then executes
|
305
|
+
# the action named `name`.
|
305
306
|
def self.dispatch(name, req, res)
|
306
307
|
if middleware_stack.any?
|
307
308
|
middleware_stack.build(name) { |env| new.dispatch(name, req, res) }.call req.env
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
require "rails"
|
4
6
|
require "action_controller"
|
5
7
|
require "action_dispatch/railtie"
|
@@ -77,6 +79,7 @@ module ActionController
|
|
77
79
|
|
78
80
|
# Configs used in other initializers
|
79
81
|
filtered_options = options.except(
|
82
|
+
:default_protect_from_forgery,
|
80
83
|
:log_query_tags_around_actions,
|
81
84
|
:permit_all_parameters,
|
82
85
|
:action_on_unpermitted_parameters,
|
@@ -1,25 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
module ActionController
|
4
|
-
#
|
6
|
+
# # Action Controller Renderer
|
5
7
|
#
|
6
8
|
# ActionController::Renderer allows you to render arbitrary templates without
|
7
9
|
# being inside a controller action.
|
8
10
|
#
|
9
|
-
# You can get a renderer instance by calling
|
11
|
+
# You can get a renderer instance by calling `renderer` on a controller class:
|
10
12
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
+
# ApplicationController.renderer
|
14
|
+
# PostsController.renderer
|
13
15
|
#
|
14
16
|
# and render a template by calling the #render method:
|
15
17
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
+
# ApplicationController.renderer.render template: "posts/show", assigns: { post: Post.first }
|
19
|
+
# PostsController.renderer.render :show, assigns: { post: Post.first }
|
18
20
|
#
|
19
|
-
# As a shortcut, you can also call
|
21
|
+
# As a shortcut, you can also call `render` directly on the controller class
|
22
|
+
# itself:
|
20
23
|
#
|
21
|
-
#
|
22
|
-
#
|
24
|
+
# ApplicationController.render template: "posts/show", assigns: { post: Post.first }
|
25
|
+
# PostsController.render :show, assigns: { post: Post.first }
|
23
26
|
#
|
24
27
|
class Renderer
|
25
28
|
attr_reader :controller
|
@@ -64,45 +67,47 @@ module ActionController
|
|
64
67
|
|
65
68
|
# Creates a new renderer using the same controller, but with a new Rack env.
|
66
69
|
#
|
67
|
-
#
|
70
|
+
# ApplicationController.renderer.new(method: "post")
|
68
71
|
#
|
69
72
|
def new(env = nil)
|
70
73
|
self.class.new controller, env, @defaults
|
71
74
|
end
|
72
75
|
|
73
|
-
# Creates a new renderer using the same controller, but with the given
|
74
|
-
#
|
76
|
+
# Creates a new renderer using the same controller, but with the given defaults
|
77
|
+
# merged on top of the previous defaults.
|
75
78
|
def with_defaults(defaults)
|
76
79
|
self.class.new controller, @env, @defaults.merge(defaults)
|
77
80
|
end
|
78
81
|
|
79
82
|
# Initializes a new Renderer.
|
80
83
|
#
|
81
|
-
#
|
84
|
+
# #### Parameters
|
85
|
+
#
|
86
|
+
# * `controller` - The controller class to instantiate for rendering.
|
87
|
+
# * `env` - The Rack env to use for mocking a request when rendering. Entries
|
88
|
+
# can be typical Rack env keys and values, or they can be any of the
|
89
|
+
# following, which will be converted appropriately:
|
90
|
+
# * `:http_host` - The HTTP host for the incoming request. Converts to
|
91
|
+
# Rack's `HTTP_HOST`.
|
92
|
+
# * `:https` - Boolean indicating whether the incoming request uses HTTPS.
|
93
|
+
# Converts to Rack's `HTTPS`.
|
94
|
+
# * `:method` - The HTTP method for the incoming request,
|
95
|
+
# case-insensitive. Converts to Rack's `REQUEST_METHOD`.
|
96
|
+
# * `:script_name` - The portion of the incoming request's URL path that
|
97
|
+
# corresponds to the application. Converts to Rack's `SCRIPT_NAME`.
|
98
|
+
# * `:input` - The input stream. Converts to Rack's `rack.input`.
|
99
|
+
#
|
100
|
+
# * `defaults` - Default values for the Rack env. Entries are specified in the
|
101
|
+
# same format as `env`. `env` will be merged on top of these values.
|
102
|
+
# `defaults` will be retained when calling #new on a renderer instance.
|
82
103
|
#
|
83
|
-
# * +controller+ - The controller class to instantiate for rendering.
|
84
|
-
# * +env+ - The Rack env to use for mocking a request when rendering.
|
85
|
-
# Entries can be typical Rack env keys and values, or they can be any of
|
86
|
-
# the following, which will be converted appropriately:
|
87
|
-
# * +:http_host+ - The HTTP host for the incoming request. Converts to
|
88
|
-
# Rack's +HTTP_HOST+.
|
89
|
-
# * +:https+ - Boolean indicating whether the incoming request uses HTTPS.
|
90
|
-
# Converts to Rack's +HTTPS+.
|
91
|
-
# * +:method+ - The HTTP method for the incoming request, case-insensitive.
|
92
|
-
# Converts to Rack's +REQUEST_METHOD+.
|
93
|
-
# * +:script_name+ - The portion of the incoming request's URL path that
|
94
|
-
# corresponds to the application. Converts to Rack's +SCRIPT_NAME+.
|
95
|
-
# * +:input+ - The input stream. Converts to Rack's +rack.input+.
|
96
|
-
# * +defaults+ - Default values for the Rack env. Entries are specified in
|
97
|
-
# the same format as +env+. +env+ will be merged on top of these values.
|
98
|
-
# +defaults+ will be retained when calling #new on a renderer instance.
|
99
104
|
#
|
100
|
-
# If no
|
101
|
-
# routes'
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
105
|
+
# If no `http_host` is specified, the env HTTP host will be derived from the
|
106
|
+
# routes' `default_url_options`. In this case, the `https` boolean and the
|
107
|
+
# `script_name` will also be derived from `default_url_options` if they were not
|
108
|
+
# specified. Additionally, the `https` boolean will fall back to
|
109
|
+
# `Rails.application.config.force_ssl` if `default_url_options` does not specify
|
110
|
+
# a `protocol`.
|
106
111
|
def initialize(controller, env, defaults)
|
107
112
|
@controller = controller
|
108
113
|
@defaults = defaults
|
@@ -119,7 +124,8 @@ module ActionController
|
|
119
124
|
@defaults
|
120
125
|
end
|
121
126
|
|
122
|
-
# Renders a template to a string, just like
|
127
|
+
# Renders a template to a string, just like
|
128
|
+
# ActionController::Rendering#render_to_string.
|
123
129
|
def render(*args)
|
124
130
|
request = ActionDispatch::Request.new(env_for_request)
|
125
131
|
request.routes = controller._routes
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :markup: markdown
|
4
|
+
|
3
5
|
module ActionController
|
4
6
|
module TemplateAssertions # :nodoc:
|
5
7
|
def assert_template(options = {}, message = nil)
|
6
8
|
raise NoMethodError,
|
7
|
-
|
8
|
-
add `gem
|
9
|
+
'assert_template has been extracted to a gem. To continue using it,
|
10
|
+
add `gem "rails-controller-testing"` to your Gemfile.'
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|