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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +355 -435
- data/MIT-LICENSE +2 -1
- data/README.rdoc +6 -7
- data/lib/abstract_controller/asset_paths.rb +1 -1
- data/lib/abstract_controller/base.rb +33 -37
- data/lib/abstract_controller/caching/fragments.rb +4 -2
- data/lib/abstract_controller/caching.rb +1 -1
- data/lib/abstract_controller/callbacks.rb +50 -11
- data/lib/abstract_controller/collector.rb +2 -2
- data/lib/abstract_controller/deprecator.rb +7 -0
- data/lib/abstract_controller/error.rb +1 -1
- data/lib/abstract_controller/helpers.rb +78 -30
- data/lib/abstract_controller/logger.rb +1 -1
- data/lib/abstract_controller/railties/routes_helpers.rb +3 -16
- data/lib/abstract_controller/rendering.rb +12 -14
- data/lib/abstract_controller/translation.rb +26 -7
- data/lib/abstract_controller/url_for.rb +6 -6
- data/lib/abstract_controller.rb +6 -0
- data/lib/action_controller/api.rb +12 -10
- data/lib/action_controller/base.rb +8 -21
- data/lib/action_controller/caching.rb +2 -0
- data/lib/action_controller/deprecator.rb +7 -0
- data/lib/action_controller/form_builder.rb +4 -2
- data/lib/action_controller/log_subscriber.rb +20 -7
- data/lib/action_controller/metal/basic_implicit_render.rb +3 -1
- data/lib/action_controller/metal/conditional_get.rb +137 -102
- data/lib/action_controller/metal/content_security_policy.rb +37 -3
- data/lib/action_controller/metal/cookies.rb +1 -1
- data/lib/action_controller/metal/data_streaming.rb +25 -31
- data/lib/action_controller/metal/default_headers.rb +2 -0
- data/lib/action_controller/metal/etag_with_flash.rb +3 -1
- data/lib/action_controller/metal/etag_with_template_digest.rb +2 -0
- data/lib/action_controller/metal/exceptions.rb +27 -30
- data/lib/action_controller/metal/flash.rb +6 -2
- data/lib/action_controller/metal/head.rb +9 -7
- data/lib/action_controller/metal/helpers.rb +5 -16
- data/lib/action_controller/metal/http_authentication.rb +78 -42
- data/lib/action_controller/metal/implicit_render.rb +5 -3
- data/lib/action_controller/metal/instrumentation.rb +62 -50
- data/lib/action_controller/metal/live.rb +67 -2
- data/lib/action_controller/metal/mime_responds.rb +5 -5
- data/lib/action_controller/metal/params_wrapper.rb +24 -13
- data/lib/action_controller/metal/permissions_policy.rb +20 -29
- data/lib/action_controller/metal/redirecting.rb +96 -23
- data/lib/action_controller/metal/renderers.rb +14 -15
- data/lib/action_controller/metal/rendering.rb +121 -16
- data/lib/action_controller/metal/request_forgery_protection.rb +208 -68
- data/lib/action_controller/metal/rescue.rb +7 -4
- data/lib/action_controller/metal/streaming.rb +74 -36
- data/lib/action_controller/metal/strong_parameters.rb +254 -151
- data/lib/action_controller/metal/testing.rb +9 -2
- data/lib/action_controller/metal/url_for.rb +10 -5
- data/lib/action_controller/metal.rb +89 -34
- data/lib/action_controller/railtie.rb +66 -9
- data/lib/action_controller/renderer.rb +99 -85
- data/lib/action_controller/test_case.rb +42 -11
- data/lib/action_controller.rb +10 -6
- data/lib/action_dispatch/constants.rb +32 -0
- data/lib/action_dispatch/deprecator.rb +7 -0
- data/lib/action_dispatch/http/cache.rb +21 -16
- data/lib/action_dispatch/http/content_security_policy.rb +122 -44
- data/lib/action_dispatch/http/filter_parameters.rb +14 -23
- data/lib/action_dispatch/http/headers.rb +3 -1
- data/lib/action_dispatch/http/mime_negotiation.rb +25 -15
- data/lib/action_dispatch/http/mime_type.rb +43 -22
- data/lib/action_dispatch/http/mime_types.rb +3 -1
- data/lib/action_dispatch/http/parameters.rb +6 -6
- data/lib/action_dispatch/http/permissions_policy.rb +57 -19
- data/lib/action_dispatch/http/rack_cache.rb +2 -0
- data/lib/action_dispatch/http/request.rb +75 -51
- data/lib/action_dispatch/http/response.rb +81 -77
- data/lib/action_dispatch/http/upload.rb +15 -2
- data/lib/action_dispatch/http/url.rb +11 -19
- data/lib/action_dispatch/journey/formatter.rb +8 -2
- data/lib/action_dispatch/journey/gtg/builder.rb +11 -12
- data/lib/action_dispatch/journey/gtg/simulator.rb +10 -4
- data/lib/action_dispatch/journey/gtg/transition_table.rb +77 -21
- data/lib/action_dispatch/journey/nodes/node.rb +70 -5
- data/lib/action_dispatch/journey/path/pattern.rb +36 -27
- data/lib/action_dispatch/journey/route.rb +8 -14
- data/lib/action_dispatch/journey/router/utils.rb +2 -2
- data/lib/action_dispatch/journey/router.rb +10 -9
- data/lib/action_dispatch/journey/routes.rb +5 -5
- data/lib/action_dispatch/journey/visualizer/fsm.js +49 -24
- data/lib/action_dispatch/journey/visualizer/index.html.erb +1 -1
- data/lib/action_dispatch/log_subscriber.rb +23 -0
- data/lib/action_dispatch/middleware/actionable_exceptions.rb +5 -7
- data/lib/action_dispatch/middleware/assume_ssl.rb +24 -0
- data/lib/action_dispatch/middleware/callbacks.rb +2 -0
- data/lib/action_dispatch/middleware/cookies.rb +97 -107
- data/lib/action_dispatch/middleware/debug_exceptions.rb +31 -28
- data/lib/action_dispatch/middleware/debug_locks.rb +7 -4
- data/lib/action_dispatch/middleware/debug_view.rb +7 -2
- data/lib/action_dispatch/middleware/exception_wrapper.rb +190 -27
- data/lib/action_dispatch/middleware/executor.rb +3 -0
- data/lib/action_dispatch/middleware/flash.rb +24 -18
- data/lib/action_dispatch/middleware/host_authorization.rb +19 -20
- data/lib/action_dispatch/middleware/public_exceptions.rb +5 -3
- data/lib/action_dispatch/middleware/reloader.rb +7 -5
- data/lib/action_dispatch/middleware/remote_ip.rb +32 -19
- data/lib/action_dispatch/middleware/request_id.rb +5 -3
- data/lib/action_dispatch/middleware/server_timing.rb +76 -0
- data/lib/action_dispatch/middleware/session/abstract_store.rb +6 -1
- data/lib/action_dispatch/middleware/session/cache_store.rb +2 -0
- data/lib/action_dispatch/middleware/session/cookie_store.rb +19 -13
- data/lib/action_dispatch/middleware/session/mem_cache_store.rb +3 -1
- data/lib/action_dispatch/middleware/show_exceptions.rb +30 -25
- data/lib/action_dispatch/middleware/ssl.rb +18 -6
- data/lib/action_dispatch/middleware/stack.rb +34 -11
- data/lib/action_dispatch/middleware/static.rb +16 -16
- data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +2 -2
- data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +5 -5
- data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +4 -11
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +8 -1
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +2 -2
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +10 -5
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +7 -3
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +9 -9
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +2 -2
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +3 -3
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +45 -18
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +19 -15
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +4 -4
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +6 -6
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +7 -7
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +4 -4
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +3 -0
- data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +64 -55
- data/lib/action_dispatch/railtie.rb +20 -4
- data/lib/action_dispatch/request/session.rb +59 -19
- data/lib/action_dispatch/request/utils.rb +8 -3
- data/lib/action_dispatch/routing/inspector.rb +55 -7
- data/lib/action_dispatch/routing/mapper.rb +117 -107
- data/lib/action_dispatch/routing/polymorphic_routes.rb +2 -0
- data/lib/action_dispatch/routing/redirection.rb +20 -8
- data/lib/action_dispatch/routing/route_set.rb +67 -27
- data/lib/action_dispatch/routing/routes_proxy.rb +11 -16
- data/lib/action_dispatch/routing/url_for.rb +29 -26
- data/lib/action_dispatch/routing.rb +12 -13
- data/lib/action_dispatch/system_test_case.rb +8 -8
- data/lib/action_dispatch/system_testing/browser.rb +20 -29
- data/lib/action_dispatch/system_testing/driver.rb +34 -18
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +35 -20
- data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +0 -8
- data/lib/action_dispatch/testing/assertion_response.rb +1 -1
- data/lib/action_dispatch/testing/assertions/response.rb +14 -7
- data/lib/action_dispatch/testing/assertions/routing.rb +70 -30
- data/lib/action_dispatch/testing/assertions.rb +3 -4
- data/lib/action_dispatch/testing/integration.rb +33 -25
- data/lib/action_dispatch/testing/request_encoder.rb +4 -1
- data/lib/action_dispatch/testing/test_process.rb +5 -30
- data/lib/action_dispatch/testing/test_request.rb +1 -1
- data/lib/action_dispatch/testing/test_response.rb +34 -2
- data/lib/action_dispatch.rb +38 -4
- data/lib/action_pack/gem_version.rb +4 -4
- data/lib/action_pack/version.rb +1 -1
- data/lib/action_pack.rb +1 -1
- metadata +67 -30
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_support/
|
3
|
+
require "active_support/html_safe_translation"
|
4
4
|
|
5
5
|
module AbstractController
|
6
6
|
module Translation
|
7
|
-
|
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
|
-
|
27
|
-
|
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>.
|
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 ||=
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
data/lib/abstract_controller.rb
CHANGED
@@ -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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
65
|
-
#
|
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
|
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
|
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
|
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
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
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,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
|
-
#
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|
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
|
|