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.

Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -642
  3. data/lib/abstract_controller/asset_paths.rb +2 -0
  4. data/lib/abstract_controller/base.rb +102 -98
  5. data/lib/abstract_controller/caching/fragments.rb +50 -53
  6. data/lib/abstract_controller/caching.rb +2 -0
  7. data/lib/abstract_controller/callbacks.rb +66 -64
  8. data/lib/abstract_controller/collector.rb +6 -6
  9. data/lib/abstract_controller/deprecator.rb +2 -0
  10. data/lib/abstract_controller/error.rb +2 -0
  11. data/lib/abstract_controller/helpers.rb +70 -85
  12. data/lib/abstract_controller/logger.rb +2 -0
  13. data/lib/abstract_controller/railties/routes_helpers.rb +2 -0
  14. data/lib/abstract_controller/rendering.rb +13 -12
  15. data/lib/abstract_controller/translation.rb +12 -13
  16. data/lib/abstract_controller/url_for.rb +8 -6
  17. data/lib/abstract_controller.rb +2 -0
  18. data/lib/action_controller/api/api_rendering.rb +2 -0
  19. data/lib/action_controller/api.rb +74 -72
  20. data/lib/action_controller/base.rb +155 -117
  21. data/lib/action_controller/caching.rb +15 -12
  22. data/lib/action_controller/deprecator.rb +2 -0
  23. data/lib/action_controller/form_builder.rb +20 -17
  24. data/lib/action_controller/log_subscriber.rb +3 -1
  25. data/lib/action_controller/metal/allow_browser.rb +119 -0
  26. data/lib/action_controller/metal/basic_implicit_render.rb +2 -0
  27. data/lib/action_controller/metal/conditional_get.rb +188 -174
  28. data/lib/action_controller/metal/content_security_policy.rb +25 -24
  29. data/lib/action_controller/metal/cookies.rb +4 -2
  30. data/lib/action_controller/metal/data_streaming.rb +64 -55
  31. data/lib/action_controller/metal/default_headers.rb +5 -3
  32. data/lib/action_controller/metal/etag_with_flash.rb +3 -1
  33. data/lib/action_controller/metal/etag_with_template_digest.rb +17 -15
  34. data/lib/action_controller/metal/exceptions.rb +11 -9
  35. data/lib/action_controller/metal/flash.rb +12 -10
  36. data/lib/action_controller/metal/head.rb +12 -10
  37. data/lib/action_controller/metal/helpers.rb +63 -55
  38. data/lib/action_controller/metal/http_authentication.rb +214 -203
  39. data/lib/action_controller/metal/implicit_render.rb +17 -15
  40. data/lib/action_controller/metal/instrumentation.rb +15 -12
  41. data/lib/action_controller/metal/live.rb +113 -107
  42. data/lib/action_controller/metal/logging.rb +6 -4
  43. data/lib/action_controller/metal/mime_responds.rb +151 -142
  44. data/lib/action_controller/metal/parameter_encoding.rb +34 -32
  45. data/lib/action_controller/metal/params_wrapper.rb +57 -59
  46. data/lib/action_controller/metal/permissions_policy.rb +13 -12
  47. data/lib/action_controller/metal/rate_limiting.rb +62 -0
  48. data/lib/action_controller/metal/redirecting.rb +108 -82
  49. data/lib/action_controller/metal/renderers.rb +50 -49
  50. data/lib/action_controller/metal/rendering.rb +103 -75
  51. data/lib/action_controller/metal/request_forgery_protection.rb +162 -133
  52. data/lib/action_controller/metal/rescue.rb +11 -9
  53. data/lib/action_controller/metal/streaming.rb +138 -136
  54. data/lib/action_controller/metal/strong_parameters.rb +483 -478
  55. data/lib/action_controller/metal/testing.rb +2 -0
  56. data/lib/action_controller/metal/url_for.rb +17 -15
  57. data/lib/action_controller/metal.rb +58 -57
  58. data/lib/action_controller/railtie.rb +3 -0
  59. data/lib/action_controller/railties/helpers.rb +2 -0
  60. data/lib/action_controller/renderer.rb +42 -36
  61. data/lib/action_controller/template_assertions.rb +4 -2
  62. data/lib/action_controller/test_case.rb +146 -126
  63. data/lib/action_controller.rb +5 -1
  64. data/lib/action_dispatch/constants.rb +2 -0
  65. data/lib/action_dispatch/deprecator.rb +2 -0
  66. data/lib/action_dispatch/http/cache.rb +27 -26
  67. data/lib/action_dispatch/http/content_disposition.rb +2 -0
  68. data/lib/action_dispatch/http/content_security_policy.rb +48 -59
  69. data/lib/action_dispatch/http/filter_parameters.rb +13 -14
  70. data/lib/action_dispatch/http/filter_redirect.rb +15 -1
  71. data/lib/action_dispatch/http/headers.rb +22 -22
  72. data/lib/action_dispatch/http/mime_negotiation.rb +30 -41
  73. data/lib/action_dispatch/http/mime_type.rb +25 -21
  74. data/lib/action_dispatch/http/mime_types.rb +2 -0
  75. data/lib/action_dispatch/http/parameters.rb +11 -9
  76. data/lib/action_dispatch/http/permissions_policy.rb +26 -36
  77. data/lib/action_dispatch/http/rack_cache.rb +2 -0
  78. data/lib/action_dispatch/http/request.rb +75 -95
  79. data/lib/action_dispatch/http/response.rb +61 -61
  80. data/lib/action_dispatch/http/upload.rb +18 -16
  81. data/lib/action_dispatch/http/url.rb +75 -73
  82. data/lib/action_dispatch/journey/formatter.rb +13 -6
  83. data/lib/action_dispatch/journey/gtg/builder.rb +4 -3
  84. data/lib/action_dispatch/journey/gtg/simulator.rb +2 -0
  85. data/lib/action_dispatch/journey/gtg/transition_table.rb +10 -8
  86. data/lib/action_dispatch/journey/nfa/dot.rb +2 -0
  87. data/lib/action_dispatch/journey/nodes/node.rb +6 -5
  88. data/lib/action_dispatch/journey/parser.rb +4 -3
  89. data/lib/action_dispatch/journey/parser_extras.rb +2 -0
  90. data/lib/action_dispatch/journey/path/pattern.rb +4 -1
  91. data/lib/action_dispatch/journey/route.rb +9 -7
  92. data/lib/action_dispatch/journey/router/utils.rb +16 -15
  93. data/lib/action_dispatch/journey/router.rb +4 -2
  94. data/lib/action_dispatch/journey/routes.rb +4 -2
  95. data/lib/action_dispatch/journey/scanner.rb +4 -2
  96. data/lib/action_dispatch/journey/visitors.rb +2 -0
  97. data/lib/action_dispatch/journey.rb +2 -0
  98. data/lib/action_dispatch/log_subscriber.rb +2 -0
  99. data/lib/action_dispatch/middleware/actionable_exceptions.rb +2 -0
  100. data/lib/action_dispatch/middleware/assume_ssl.rb +8 -5
  101. data/lib/action_dispatch/middleware/callbacks.rb +3 -1
  102. data/lib/action_dispatch/middleware/cookies.rb +119 -104
  103. data/lib/action_dispatch/middleware/debug_exceptions.rb +13 -5
  104. data/lib/action_dispatch/middleware/debug_locks.rb +15 -13
  105. data/lib/action_dispatch/middleware/debug_view.rb +2 -0
  106. data/lib/action_dispatch/middleware/exception_wrapper.rb +6 -11
  107. data/lib/action_dispatch/middleware/executor.rb +2 -0
  108. data/lib/action_dispatch/middleware/flash.rb +63 -51
  109. data/lib/action_dispatch/middleware/host_authorization.rb +17 -15
  110. data/lib/action_dispatch/middleware/public_exceptions.rb +8 -6
  111. data/lib/action_dispatch/middleware/reloader.rb +5 -3
  112. data/lib/action_dispatch/middleware/remote_ip.rb +77 -72
  113. data/lib/action_dispatch/middleware/request_id.rb +14 -9
  114. data/lib/action_dispatch/middleware/server_timing.rb +4 -2
  115. data/lib/action_dispatch/middleware/session/abstract_store.rb +2 -0
  116. data/lib/action_dispatch/middleware/session/cache_store.rb +13 -8
  117. data/lib/action_dispatch/middleware/session/cookie_store.rb +27 -26
  118. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -3
  119. data/lib/action_dispatch/middleware/show_exceptions.rb +16 -16
  120. data/lib/action_dispatch/middleware/ssl.rb +43 -40
  121. data/lib/action_dispatch/middleware/stack.rb +11 -10
  122. data/lib/action_dispatch/middleware/static.rb +33 -31
  123. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +1 -1
  124. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +1 -1
  125. data/lib/action_dispatch/railtie.rb +2 -3
  126. data/lib/action_dispatch/request/session.rb +23 -21
  127. data/lib/action_dispatch/request/utils.rb +2 -0
  128. data/lib/action_dispatch/routing/endpoint.rb +2 -0
  129. data/lib/action_dispatch/routing/inspector.rb +6 -4
  130. data/lib/action_dispatch/routing/mapper.rb +623 -625
  131. data/lib/action_dispatch/routing/polymorphic_routes.rb +69 -62
  132. data/lib/action_dispatch/routing/redirection.rb +37 -32
  133. data/lib/action_dispatch/routing/route_set.rb +60 -46
  134. data/lib/action_dispatch/routing/routes_proxy.rb +6 -4
  135. data/lib/action_dispatch/routing/url_for.rb +130 -125
  136. data/lib/action_dispatch/routing.rb +150 -148
  137. data/lib/action_dispatch/system_test_case.rb +91 -81
  138. data/lib/action_dispatch/system_testing/browser.rb +4 -2
  139. data/lib/action_dispatch/system_testing/driver.rb +2 -0
  140. data/lib/action_dispatch/system_testing/server.rb +2 -0
  141. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +32 -21
  142. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +2 -0
  143. data/lib/action_dispatch/testing/assertion_response.rb +8 -6
  144. data/lib/action_dispatch/testing/assertions/response.rb +26 -23
  145. data/lib/action_dispatch/testing/assertions/routing.rb +153 -84
  146. data/lib/action_dispatch/testing/assertions.rb +2 -0
  147. data/lib/action_dispatch/testing/integration.rb +223 -222
  148. data/lib/action_dispatch/testing/request_encoder.rb +2 -0
  149. data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +35 -0
  150. data/lib/action_dispatch/testing/test_process.rb +12 -8
  151. data/lib/action_dispatch/testing/test_request.rb +3 -1
  152. data/lib/action_dispatch/testing/test_response.rb +27 -26
  153. data/lib/action_dispatch.rb +22 -32
  154. data/lib/action_pack/gem_version.rb +6 -4
  155. data/lib/action_pack/version.rb +3 -1
  156. data/lib/action_pack.rb +17 -16
  157. metadata +33 -16
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :markup: markdown
4
+
3
5
  module ActionController
4
6
  module Testing
5
7
  # Behavior specific to functional tests
@@ -1,27 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :markup: markdown
4
+
3
5
  module ActionController
4
- # = Action Controller \UrlFor
6
+ # # Action Controller UrlFor
5
7
  #
6
- # Includes +url_for+ into the host class. The class has to provide a +RouteSet+ by implementing
7
- # the <tt>_routes</tt> method. Otherwise, an exception will be raised.
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 to define
10
- # URL options like the +host+. In order to do so, this module requires the host class
11
- # to implement +env+ which needs to be Rack-compatible, and +request+ which
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
- # class RootUrl
15
- # include ActionController::UrlFor
16
- # include Rails.application.routes.url_helpers
16
+ # class RootUrl
17
+ # include ActionController::UrlFor
18
+ # include Rails.application.routes.url_helpers
17
19
  #
18
- # delegate :env, :request, to: :controller
20
+ # delegate :env, :request, to: :controller
19
21
  #
20
- # def initialize(controller)
21
- # @controller = controller
22
- # @url = root_path # named route from the application.
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
- # = Action Controller \MiddlewareStack
9
+ # # Action Controller MiddlewareStack
8
10
  #
9
- # Extend ActionDispatch middleware stack to make it aware of options
10
- # allowing the following syntax in controllers:
11
+ # Extend ActionDispatch middleware stack to make it aware of options allowing
12
+ # the following syntax in controllers:
11
13
  #
12
- # class PostsController < ApplicationController
13
- # use AuthenticationMiddleware, except: [:index, :show]
14
- # end
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
- # = Action Controller \Metal
65
+ # # Action Controller Metal
64
66
  #
65
- # +ActionController::Metal+ is the simplest possible controller, providing a
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
- # class HelloController < ActionController::Metal
72
- # def index
73
- # self.response_body = "Hello World!"
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
- # something like this to <tt>config/routes.rb</tt>:
79
+ # And then to route requests to your metal controller, you would add something
80
+ # like this to `config/routes.rb`:
79
81
  #
80
- # get 'hello', to: HelloController.action(:index)
82
+ # get 'hello', to: HelloController.action(:index)
81
83
  #
82
- # The +action+ method returns a valid Rack application for the \Rails
83
- # router to dispatch to.
84
+ # The `action` method returns a valid Rack application for the Rails router to
85
+ # dispatch to.
84
86
  #
85
- # == \Rendering \Helpers
87
+ # ## Rendering Helpers
86
88
  #
87
- # +ActionController::Metal+ by default provides no utilities for rendering
89
+ # `ActionController::Metal` by default provides no utilities for rendering
88
90
  # views, partials, or other responses aside from explicitly calling of
89
- # <tt>response_body=</tt>, <tt>content_type=</tt>, and <tt>status=</tt>. To
90
- # add the render helpers you're used to having in a normal controller, you
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
- # class HelloController < ActionController::Metal
94
- # include AbstractController::Rendering
95
- # include ActionView::Layouts
96
- # append_view_path "#{Rails.root}/app/views"
94
+ # class HelloController < ActionController::Metal
95
+ # include AbstractController::Rendering
96
+ # include ActionView::Layouts
97
+ # append_view_path "#{Rails.root}/app/views"
97
98
  #
98
- # def index
99
- # render "hello/index"
99
+ # def index
100
+ # render "hello/index"
101
+ # end
100
102
  # end
101
- # end
102
103
  #
103
- # == Redirection \Helpers
104
+ # ## Redirection Helpers
104
105
  #
105
106
  # To add redirection helpers to your metal controller, do the following:
106
107
  #
107
- # class HelloController < ActionController::Metal
108
- # include ActionController::Redirecting
109
- # include Rails.application.routes.url_helpers
108
+ # class HelloController < ActionController::Metal
109
+ # include ActionController::Redirecting
110
+ # include Rails.application.routes.url_helpers
110
111
  #
111
- # def index
112
- # redirect_to root_url
112
+ # def index
113
+ # redirect_to root_url
114
+ # end
113
115
  # end
114
- # end
115
- #
116
- # == Other \Helpers
117
116
  #
118
- # You can refer to the modules included in ActionController::Base to see
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 ending
125
- # <tt>Controller</tt>. For instance, +PostsController+ returns <tt>posts</tt>.
126
- # Namespaces are left out, so +Admin::PostsController+ returns <tt>posts</tt> as well.
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
- # ==== Returns
129
- # * <tt>string</tt>
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
- # {Active Controller Session guide}[https://guides.rubyonrails.org/action_controller_overview.html#session].
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 \url_for that can be overridden for more robust functionality.
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 occur.
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
- # allows for the following syntax:
275
+ # By default uses a variation of ActionDispatch::MiddlewareStack which allows
276
+ # for the following syntax:
276
277
  #
277
- # class PostsController < ApplicationController
278
- # use AuthenticationMiddleware, except: [:index, :show]
279
- # end
278
+ # class PostsController < ApplicationController
279
+ # use AuthenticationMiddleware, except: [:index, :show]
280
+ # end
280
281
  #
281
- # Read more about {Rails middleware
282
- # stack}[https://guides.rubyonrails.org/rails_on_rack.html#action-dispatcher-middleware-stack]
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
- # executes the action named +name+.
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,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :markup: markdown
4
+
3
5
  module ActionController
4
6
  module Railties
5
7
  module Helpers
@@ -1,25 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :markup: markdown
4
+
3
5
  module ActionController
4
- # = Action Controller \Renderer
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 +renderer+ on a controller class:
11
+ # You can get a renderer instance by calling `renderer` on a controller class:
10
12
  #
11
- # ApplicationController.renderer
12
- # PostsController.renderer
13
+ # ApplicationController.renderer
14
+ # PostsController.renderer
13
15
  #
14
16
  # and render a template by calling the #render method:
15
17
  #
16
- # ApplicationController.renderer.render template: "posts/show", assigns: { post: Post.first }
17
- # PostsController.renderer.render :show, assigns: { post: Post.first }
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 +render+ directly on the controller class itself:
21
+ # As a shortcut, you can also call `render` directly on the controller class
22
+ # itself:
20
23
  #
21
- # ApplicationController.render template: "posts/show", assigns: { post: Post.first }
22
- # PostsController.render :show, assigns: { post: Post.first }
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
- # ApplicationController.renderer.new(method: "post")
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
- # defaults merged on top of the previous defaults.
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
- # ==== Parameters
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 +http_host+ is specified, the env HTTP host will be derived from the
101
- # routes' +default_url_options+. In this case, the +https+ boolean and the
102
- # +script_name+ will also be derived from +default_url_options+ if they were
103
- # not specified. Additionally, the +https+ boolean will fall back to
104
- # +Rails.application.config.force_ssl+ if +default_url_options+ does not
105
- # specify a +protocol+.
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 ActionController::Rendering#render_to_string.
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
- "assert_template has been extracted to a gem. To continue using it,
8
- add `gem 'rails-controller-testing'` to your Gemfile."
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