actionpack 6.1.7.5 → 7.1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +355 -435
  3. data/MIT-LICENSE +2 -1
  4. data/README.rdoc +6 -7
  5. data/lib/abstract_controller/asset_paths.rb +1 -1
  6. data/lib/abstract_controller/base.rb +33 -37
  7. data/lib/abstract_controller/caching/fragments.rb +4 -2
  8. data/lib/abstract_controller/caching.rb +1 -1
  9. data/lib/abstract_controller/callbacks.rb +50 -11
  10. data/lib/abstract_controller/collector.rb +2 -2
  11. data/lib/abstract_controller/deprecator.rb +7 -0
  12. data/lib/abstract_controller/error.rb +1 -1
  13. data/lib/abstract_controller/helpers.rb +78 -30
  14. data/lib/abstract_controller/logger.rb +1 -1
  15. data/lib/abstract_controller/railties/routes_helpers.rb +3 -16
  16. data/lib/abstract_controller/rendering.rb +12 -14
  17. data/lib/abstract_controller/translation.rb +26 -7
  18. data/lib/abstract_controller/url_for.rb +6 -6
  19. data/lib/abstract_controller.rb +6 -0
  20. data/lib/action_controller/api.rb +12 -10
  21. data/lib/action_controller/base.rb +8 -21
  22. data/lib/action_controller/caching.rb +2 -0
  23. data/lib/action_controller/deprecator.rb +7 -0
  24. data/lib/action_controller/form_builder.rb +4 -2
  25. data/lib/action_controller/log_subscriber.rb +20 -7
  26. data/lib/action_controller/metal/basic_implicit_render.rb +3 -1
  27. data/lib/action_controller/metal/conditional_get.rb +137 -102
  28. data/lib/action_controller/metal/content_security_policy.rb +37 -3
  29. data/lib/action_controller/metal/cookies.rb +1 -1
  30. data/lib/action_controller/metal/data_streaming.rb +25 -31
  31. data/lib/action_controller/metal/default_headers.rb +2 -0
  32. data/lib/action_controller/metal/etag_with_flash.rb +3 -1
  33. data/lib/action_controller/metal/etag_with_template_digest.rb +2 -0
  34. data/lib/action_controller/metal/exceptions.rb +27 -30
  35. data/lib/action_controller/metal/flash.rb +6 -2
  36. data/lib/action_controller/metal/head.rb +9 -7
  37. data/lib/action_controller/metal/helpers.rb +5 -16
  38. data/lib/action_controller/metal/http_authentication.rb +78 -42
  39. data/lib/action_controller/metal/implicit_render.rb +5 -3
  40. data/lib/action_controller/metal/instrumentation.rb +62 -50
  41. data/lib/action_controller/metal/live.rb +67 -2
  42. data/lib/action_controller/metal/mime_responds.rb +5 -5
  43. data/lib/action_controller/metal/params_wrapper.rb +24 -13
  44. data/lib/action_controller/metal/permissions_policy.rb +20 -29
  45. data/lib/action_controller/metal/redirecting.rb +96 -23
  46. data/lib/action_controller/metal/renderers.rb +14 -15
  47. data/lib/action_controller/metal/rendering.rb +121 -16
  48. data/lib/action_controller/metal/request_forgery_protection.rb +208 -68
  49. data/lib/action_controller/metal/rescue.rb +7 -4
  50. data/lib/action_controller/metal/streaming.rb +74 -36
  51. data/lib/action_controller/metal/strong_parameters.rb +254 -151
  52. data/lib/action_controller/metal/testing.rb +9 -2
  53. data/lib/action_controller/metal/url_for.rb +10 -5
  54. data/lib/action_controller/metal.rb +89 -34
  55. data/lib/action_controller/railtie.rb +66 -9
  56. data/lib/action_controller/renderer.rb +99 -85
  57. data/lib/action_controller/test_case.rb +42 -11
  58. data/lib/action_controller.rb +10 -6
  59. data/lib/action_dispatch/constants.rb +32 -0
  60. data/lib/action_dispatch/deprecator.rb +7 -0
  61. data/lib/action_dispatch/http/cache.rb +21 -16
  62. data/lib/action_dispatch/http/content_security_policy.rb +122 -44
  63. data/lib/action_dispatch/http/filter_parameters.rb +14 -23
  64. data/lib/action_dispatch/http/headers.rb +3 -1
  65. data/lib/action_dispatch/http/mime_negotiation.rb +25 -15
  66. data/lib/action_dispatch/http/mime_type.rb +43 -22
  67. data/lib/action_dispatch/http/mime_types.rb +3 -1
  68. data/lib/action_dispatch/http/parameters.rb +6 -6
  69. data/lib/action_dispatch/http/permissions_policy.rb +57 -19
  70. data/lib/action_dispatch/http/rack_cache.rb +2 -0
  71. data/lib/action_dispatch/http/request.rb +75 -51
  72. data/lib/action_dispatch/http/response.rb +81 -77
  73. data/lib/action_dispatch/http/upload.rb +15 -2
  74. data/lib/action_dispatch/http/url.rb +11 -19
  75. data/lib/action_dispatch/journey/formatter.rb +8 -2
  76. data/lib/action_dispatch/journey/gtg/builder.rb +11 -12
  77. data/lib/action_dispatch/journey/gtg/simulator.rb +10 -4
  78. data/lib/action_dispatch/journey/gtg/transition_table.rb +77 -21
  79. data/lib/action_dispatch/journey/nodes/node.rb +70 -5
  80. data/lib/action_dispatch/journey/path/pattern.rb +36 -27
  81. data/lib/action_dispatch/journey/route.rb +8 -14
  82. data/lib/action_dispatch/journey/router/utils.rb +2 -2
  83. data/lib/action_dispatch/journey/router.rb +10 -9
  84. data/lib/action_dispatch/journey/routes.rb +5 -5
  85. data/lib/action_dispatch/journey/visualizer/fsm.js +49 -24
  86. data/lib/action_dispatch/journey/visualizer/index.html.erb +1 -1
  87. data/lib/action_dispatch/log_subscriber.rb +23 -0
  88. data/lib/action_dispatch/middleware/actionable_exceptions.rb +5 -7
  89. data/lib/action_dispatch/middleware/assume_ssl.rb +24 -0
  90. data/lib/action_dispatch/middleware/callbacks.rb +2 -0
  91. data/lib/action_dispatch/middleware/cookies.rb +97 -107
  92. data/lib/action_dispatch/middleware/debug_exceptions.rb +31 -28
  93. data/lib/action_dispatch/middleware/debug_locks.rb +7 -4
  94. data/lib/action_dispatch/middleware/debug_view.rb +7 -2
  95. data/lib/action_dispatch/middleware/exception_wrapper.rb +190 -27
  96. data/lib/action_dispatch/middleware/executor.rb +3 -0
  97. data/lib/action_dispatch/middleware/flash.rb +24 -18
  98. data/lib/action_dispatch/middleware/host_authorization.rb +19 -20
  99. data/lib/action_dispatch/middleware/public_exceptions.rb +5 -3
  100. data/lib/action_dispatch/middleware/reloader.rb +7 -5
  101. data/lib/action_dispatch/middleware/remote_ip.rb +32 -19
  102. data/lib/action_dispatch/middleware/request_id.rb +5 -3
  103. data/lib/action_dispatch/middleware/server_timing.rb +76 -0
  104. data/lib/action_dispatch/middleware/session/abstract_store.rb +6 -1
  105. data/lib/action_dispatch/middleware/session/cache_store.rb +2 -0
  106. data/lib/action_dispatch/middleware/session/cookie_store.rb +19 -13
  107. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +3 -1
  108. data/lib/action_dispatch/middleware/show_exceptions.rb +30 -25
  109. data/lib/action_dispatch/middleware/ssl.rb +18 -6
  110. data/lib/action_dispatch/middleware/stack.rb +34 -11
  111. data/lib/action_dispatch/middleware/static.rb +16 -16
  112. data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +2 -2
  113. data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +5 -5
  114. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +4 -11
  115. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +8 -1
  116. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +2 -2
  117. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +10 -5
  118. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +7 -3
  119. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +9 -9
  120. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +2 -2
  121. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +3 -3
  122. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +45 -18
  123. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +19 -15
  124. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +4 -4
  125. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +6 -6
  126. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +7 -7
  127. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +4 -4
  128. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +1 -1
  129. data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +3 -0
  130. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +64 -55
  131. data/lib/action_dispatch/railtie.rb +20 -4
  132. data/lib/action_dispatch/request/session.rb +59 -19
  133. data/lib/action_dispatch/request/utils.rb +8 -3
  134. data/lib/action_dispatch/routing/inspector.rb +55 -7
  135. data/lib/action_dispatch/routing/mapper.rb +117 -107
  136. data/lib/action_dispatch/routing/polymorphic_routes.rb +2 -0
  137. data/lib/action_dispatch/routing/redirection.rb +20 -8
  138. data/lib/action_dispatch/routing/route_set.rb +67 -27
  139. data/lib/action_dispatch/routing/routes_proxy.rb +11 -16
  140. data/lib/action_dispatch/routing/url_for.rb +29 -26
  141. data/lib/action_dispatch/routing.rb +12 -13
  142. data/lib/action_dispatch/system_test_case.rb +8 -8
  143. data/lib/action_dispatch/system_testing/browser.rb +20 -29
  144. data/lib/action_dispatch/system_testing/driver.rb +34 -18
  145. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +35 -20
  146. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +0 -8
  147. data/lib/action_dispatch/testing/assertion_response.rb +1 -1
  148. data/lib/action_dispatch/testing/assertions/response.rb +14 -7
  149. data/lib/action_dispatch/testing/assertions/routing.rb +70 -30
  150. data/lib/action_dispatch/testing/assertions.rb +3 -4
  151. data/lib/action_dispatch/testing/integration.rb +33 -25
  152. data/lib/action_dispatch/testing/request_encoder.rb +4 -1
  153. data/lib/action_dispatch/testing/test_process.rb +5 -30
  154. data/lib/action_dispatch/testing/test_request.rb +1 -1
  155. data/lib/action_dispatch/testing/test_response.rb +34 -2
  156. data/lib/action_dispatch.rb +38 -4
  157. data/lib/action_pack/gem_version.rb +4 -4
  158. data/lib/action_pack/version.rb +1 -1
  159. data/lib/action_pack.rb +1 -1
  160. metadata +67 -30
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/symbol/starts_ends_with"
3
+ require "active_support/html_safe_translation"
4
4
 
5
5
  module AbstractController
6
6
  module Translation
7
- mattr_accessor :raise_on_missing_translations, default: false
8
-
9
- # Delegates to <tt>I18n.translate</tt>. Also aliased as <tt>t</tt>.
7
+ # Delegates to <tt>I18n.translate</tt>.
10
8
  #
11
9
  # When the given key starts with a period, it will be scoped by the current
12
10
  # controller and action. So if you call <tt>translate(".foo")</tt> from
@@ -23,15 +21,36 @@ module AbstractController
23
21
  key = "#{path}.#{action_name}#{key}"
24
22
  end
25
23
 
26
- i18n_raise = options.fetch(:raise, self.raise_on_missing_translations)
27
- I18n.translate(key, **options, raise: i18n_raise)
24
+ if options[:default]
25
+ options[:default] = [options[:default]] unless options[:default].is_a?(Array)
26
+ options[:default] = options[:default].map do |value|
27
+ value.is_a?(String) ? ERB::Util.html_escape(value) : value
28
+ end
29
+ end
30
+
31
+ if options[:raise].nil?
32
+ options[:default] = [] unless options[:default]
33
+ options[:default] << MISSING_TRANSLATION
34
+ end
35
+
36
+ result = ActiveSupport::HtmlSafeTranslation.translate(key, **options)
37
+
38
+ if result == MISSING_TRANSLATION
39
+ +"translation missing: #{key}"
40
+ else
41
+ result
42
+ end
28
43
  end
29
44
  alias :t :translate
30
45
 
31
- # Delegates to <tt>I18n.localize</tt>. Also aliased as <tt>l</tt>.
46
+ # Delegates to <tt>I18n.localize</tt>.
32
47
  def localize(object, **options)
33
48
  I18n.localize(object, **options)
34
49
  end
35
50
  alias :l :localize
51
+
52
+ private
53
+ MISSING_TRANSLATION = -(2**60)
54
+ private_constant :MISSING_TRANSLATION
36
55
  end
37
56
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbstractController
4
+ # = URL For
5
+ #
4
6
  # Includes +url_for+ into the host class (e.g. an abstract controller or mailer). The class
5
7
  # has to provide a +RouteSet+ by implementing the <tt>_routes</tt> methods. Otherwise, an
6
8
  # exception will be raised.
@@ -22,12 +24,10 @@ module AbstractController
22
24
  end
23
25
 
24
26
  def action_methods
25
- @action_methods ||= begin
26
- if _routes
27
- super - _routes.named_routes.helper_names
28
- else
29
- super
30
- end
27
+ @action_methods ||= if _routes
28
+ super - _routes.named_routes.helper_names
29
+ else
30
+ super
31
31
  end
32
32
  end
33
33
  end
@@ -4,6 +4,7 @@ require "action_pack"
4
4
  require "active_support"
5
5
  require "active_support/rails"
6
6
  require "active_support/i18n"
7
+ require "abstract_controller/deprecator"
7
8
 
8
9
  module AbstractController
9
10
  extend ActiveSupport::Autoload
@@ -24,5 +25,10 @@ module AbstractController
24
25
  def self.eager_load!
25
26
  super
26
27
  AbstractController::Caching.eager_load!
28
+ AbstractController::Base.descendants.each do |controller|
29
+ unless controller.abstract?
30
+ controller.eager_load!
31
+ end
32
+ end
27
33
  end
28
34
  end
@@ -5,7 +5,9 @@ require "action_controller"
5
5
  require "action_controller/log_subscriber"
6
6
 
7
7
  module ActionController
8
- # API Controller is a lightweight version of <tt>ActionController::Base</tt>,
8
+ # = Action Controller \API
9
+ #
10
+ # API Controller is a lightweight version of ActionController::Base,
9
11
  # created for applications that don't require all functionalities that a complete
10
12
  # \Rails controller provides, allowing you to create controllers with just the
11
13
  # features that you need for API only applications.
@@ -19,7 +21,7 @@ module ActionController
19
21
  # your application, they're just not part of the default API controller stack.
20
22
  #
21
23
  # Normally, +ApplicationController+ is the only controller that inherits from
22
- # <tt>ActionController::API</tt>. All other controllers in turn inherit from
24
+ # +ActionController::API+. All other controllers in turn inherit from
23
25
  # +ApplicationController+.
24
26
  #
25
27
  # A sample controller could look like this:
@@ -32,15 +34,15 @@ module ActionController
32
34
  # end
33
35
  #
34
36
  # Request, response, and parameters objects all work the exact same way as
35
- # <tt>ActionController::Base</tt>.
37
+ # ActionController::Base.
36
38
  #
37
39
  # == Renders
38
40
  #
39
41
  # The default API Controller stack includes all renderers, which means you
40
- # can use <tt>render :json</tt> and brothers freely in your controllers. Keep
42
+ # can use <tt>render :json</tt> and siblings freely in your controllers. Keep
41
43
  # in mind that templates are not going to be rendered, so you need to ensure
42
44
  # your controller is calling either <tt>render</tt> or <tt>redirect_to</tt> in
43
- # all actions, otherwise it will return 204 No Content.
45
+ # all actions, otherwise it will return <tt>204 No Content</tt>.
44
46
  #
45
47
  # def show
46
48
  # post = Post.find(params[:id])
@@ -51,7 +53,7 @@ module ActionController
51
53
  #
52
54
  # Redirects are used to move from one action to another. You can use the
53
55
  # <tt>redirect_to</tt> method in your controllers in the same way as in
54
- # <tt>ActionController::Base</tt>. For example:
56
+ # ActionController::Base. For example:
55
57
  #
56
58
  # def create
57
59
  # redirect_to root_url and return if not_authorized?
@@ -61,8 +63,8 @@ module ActionController
61
63
  # == Adding New Behavior
62
64
  #
63
65
  # In some scenarios you may want to add back some functionality provided by
64
- # <tt>ActionController::Base</tt> that is not present by default in
65
- # <tt>ActionController::API</tt>, for instance <tt>MimeResponds</tt>. This
66
+ # ActionController::Base that is not present by default in
67
+ # +ActionController::API+, for instance <tt>MimeResponds</tt>. This
66
68
  # module gives you the <tt>respond_to</tt> method. Adding it is quite simple,
67
69
  # you just need to include the module in a specific controller or in
68
70
  # +ApplicationController+ in case you want it available in your entire
@@ -83,9 +85,9 @@ module ActionController
83
85
  # end
84
86
  # end
85
87
  #
86
- # Make sure to check the modules included in <tt>ActionController::Base</tt>
88
+ # Make sure to check the modules included in ActionController::Base
87
89
  # if you want to use any other functionality that is not provided
88
- # by <tt>ActionController::API</tt> out of the box.
90
+ # by +ActionController::API+ out of the box.
89
91
  class API < Metal
90
92
  abstract!
91
93
 
@@ -5,11 +5,13 @@ require "action_controller/log_subscriber"
5
5
  require "action_controller/metal/params_wrapper"
6
6
 
7
7
  module ActionController
8
+ # = Action Controller \Base
9
+ #
8
10
  # Action Controllers are the core of a web request in \Rails. They are made up of one or more actions that are executed
9
11
  # on request and then either it renders a template or redirects to another action. An action is defined as a public method
10
12
  # on the controller, which will automatically be made accessible to the web-server through \Rails Routes.
11
13
  #
12
- # By default, only the ApplicationController in a \Rails application inherits from <tt>ActionController::Base</tt>. All other
14
+ # By default, only the ApplicationController in a \Rails application inherits from +ActionController::Base+. All other
13
15
  # controllers inherit from ApplicationController. This gives you one class to configure things such as
14
16
  # request forgery protection and filtering of sensitive request parameters.
15
17
  #
@@ -87,10 +89,11 @@ module ActionController
87
89
  #
88
90
  # or you can remove the entire session with +reset_session+.
89
91
  #
90
- # Sessions are stored by default in a browser cookie that's cryptographically signed, but unencrypted.
91
- # This prevents the user from tampering with the session but also allows them to see its contents.
92
- #
93
- # Do not put secret information in cookie-based sessions!
92
+ # By default, sessions are stored in an encrypted browser cookie (see
93
+ # ActionDispatch::Session::CookieStore). Thus the user will not be able to
94
+ # read or edit the session data. However, the user can keep a copy of the
95
+ # cookie even after it has expired, so you should avoid storing sensitive
96
+ # information in cookie-based sessions.
94
97
  #
95
98
  # == Responses
96
99
  #
@@ -166,22 +169,6 @@ module ActionController
166
169
  class Base < Metal
167
170
  abstract!
168
171
 
169
- # We document the request and response methods here because albeit they are
170
- # implemented in ActionController::Metal, the type of the returned objects
171
- # is unknown at that level.
172
-
173
- ##
174
- # :method: request
175
- #
176
- # Returns an ActionDispatch::Request instance that represents the
177
- # current request.
178
-
179
- ##
180
- # :method: response
181
- #
182
- # Returns an ActionDispatch::Response that represents the current
183
- # response.
184
-
185
172
  # Shortcut helper that returns all the modules included in
186
173
  # ActionController::Base except the ones passed as arguments:
187
174
  #
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionController
4
+ # = Action Controller \Caching
5
+ #
4
6
  # \Caching is a cheap way of speeding up slow applications by keeping the result of
5
7
  # calculations, renderings, and database calls around for subsequent requests.
6
8
  #
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionController
4
+ def self.deprecator # :nodoc:
5
+ AbstractController.deprecator
6
+ end
7
+ end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionController
4
+ # = Action Controller Form Builder
5
+ #
4
6
  # Override the default form builder for all views rendered by this
5
7
  # controller and any of its descendants. Accepts a subclass of
6
- # +ActionView::Helpers::FormBuilder+.
8
+ # ActionView::Helpers::FormBuilder.
7
9
  #
8
10
  # For example, given a form builder:
9
11
  #
@@ -36,7 +38,7 @@ module ActionController
36
38
  # in the views rendered by this controller and its subclasses.
37
39
  #
38
40
  # ==== Parameters
39
- # * <tt>builder</tt> - Default form builder, an instance of +ActionView::Helpers::FormBuilder+
41
+ # * <tt>builder</tt> - Default form builder, an instance of ActionView::Helpers::FormBuilder
40
42
  def default_form_builder(builder)
41
43
  self._default_form_builder = builder
42
44
  end
@@ -8,7 +8,10 @@ module ActionController
8
8
  return unless logger.info?
9
9
 
10
10
  payload = event.payload
11
- params = payload[:params].except(*INTERNAL_PARAMS)
11
+ params = {}
12
+ payload[:params].each_pair do |k, v|
13
+ params[k] = v unless INTERNAL_PARAMS.include?(k)
14
+ end
12
15
  format = payload[:format]
13
16
  format = format.to_s.upcase if format.is_a?(Symbol)
14
17
  format = "*/*" if format.nil?
@@ -16,6 +19,7 @@ module ActionController
16
19
  info "Processing by #{payload[:controller]}##{payload[:action]} as #{format}"
17
20
  info " Parameters: #{params.inspect}" unless params.empty?
18
21
  end
22
+ subscribe_log_level :start_processing, :info
19
23
 
20
24
  def process_action(event)
21
25
  info do
@@ -29,46 +33,55 @@ module ActionController
29
33
 
30
34
  additions << "Allocations: #{event.allocations}"
31
35
 
32
- message = +"Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in #{event.duration.round}ms"
33
- message << " (#{additions.join(" | ")})"
36
+ message = +"Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in #{event.duration.round}ms" \
37
+ " (#{additions.join(" | ")})"
34
38
  message << "\n\n" if defined?(Rails.env) && Rails.env.development?
35
39
 
36
40
  message
37
41
  end
38
42
  end
43
+ subscribe_log_level :process_action, :info
39
44
 
40
45
  def halted_callback(event)
41
46
  info { "Filter chain halted as #{event.payload[:filter].inspect} rendered or redirected" }
42
47
  end
48
+ subscribe_log_level :halted_callback, :info
43
49
 
44
50
  def send_file(event)
45
51
  info { "Sent file #{event.payload[:path]} (#{event.duration.round(1)}ms)" }
46
52
  end
53
+ subscribe_log_level :send_file, :info
47
54
 
48
55
  def redirect_to(event)
49
56
  info { "Redirected to #{event.payload[:location]}" }
50
57
  end
58
+ subscribe_log_level :redirect_to, :info
51
59
 
52
60
  def send_data(event)
53
61
  info { "Sent data #{event.payload[:filename]} (#{event.duration.round(1)}ms)" }
54
62
  end
63
+ subscribe_log_level :send_data, :info
55
64
 
56
65
  def unpermitted_parameters(event)
57
66
  debug do
58
67
  unpermitted_keys = event.payload[:keys]
59
- color("Unpermitted parameter#{'s' if unpermitted_keys.size > 1}: #{unpermitted_keys.map { |e| ":#{e}" }.join(", ")}", RED)
68
+ display_unpermitted_keys = unpermitted_keys.map { |e| ":#{e}" }.join(", ")
69
+ context = event.payload[:context].map { |k, v| "#{k}: #{v}" }.join(", ")
70
+ color("Unpermitted parameter#{'s' if unpermitted_keys.size > 1}: #{display_unpermitted_keys}. Context: { #{context} }", RED)
60
71
  end
61
72
  end
73
+ subscribe_log_level :unpermitted_parameters, :debug
62
74
 
63
- %w(write_fragment read_fragment exist_fragment?
64
- expire_fragment expire_page write_page).each do |method|
75
+ %w(write_fragment read_fragment exist_fragment? expire_fragment).each do |method|
65
76
  class_eval <<-METHOD, __FILE__, __LINE__ + 1
77
+ # frozen_string_literal: true
66
78
  def #{method}(event)
67
- return unless logger.info? && ActionController::Base.enable_fragment_cache_logging
79
+ return unless ActionController::Base.enable_fragment_cache_logging
68
80
  key = ActiveSupport::Cache.expand_cache_key(event.payload[:key] || event.payload[:path])
69
81
  human_name = #{method.to_s.humanize.inspect}
70
82
  info("\#{human_name} \#{key} (\#{event.duration.round(1)}ms)")
71
83
  end
84
+ subscribe_log_level :#{method}, :info
72
85
  METHOD
73
86
  end
74
87
 
@@ -3,7 +3,9 @@
3
3
  module ActionController
4
4
  module BasicImplicitRender # :nodoc:
5
5
  def send_action(method, *args)
6
- super.tap { default_render unless performed? }
6
+ ret = super
7
+ default_render unless performed?
8
+ ret
7
9
  end
8
10
 
9
11
  def default_render