Stop relying on mutating the configuration object

This commit is contained in:
Rafael Mendonça França 2021-08-17 23:21:52 +00:00
parent 8af78700d2
commit a6aa9376f1
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
2 changed files with 14 additions and 7 deletions

View File

@ -27,14 +27,13 @@ module ActionController
options = app.config.action_controller
ActiveSupport.on_load(:action_controller, run_once: true) do
ActionController::Parameters.permit_all_parameters = options.delete(:permit_all_parameters) { false }
ActionController::Parameters.permit_all_parameters = options.permit_all_parameters || false
if app.config.action_controller[:always_permitted_parameters]
ActionController::Parameters.always_permitted_parameters =
app.config.action_controller.delete(:always_permitted_parameters)
app.config.action_controller.always_permitted_parameters
end
ActionController::Parameters.action_on_unpermitted_parameters = options.delete(:action_on_unpermitted_parameters) do
ActionController::Parameters.action_on_unpermitted_parameters = options.action_on_unpermitted_parameters ||
(Rails.env.test? || Rails.env.development?) ? :log : false
end
end
end
@ -53,7 +52,12 @@ module ActionController
options.relative_url_root ||= app.config.relative_url_root
# Configs used in other initializers
options = options.except(:log_query_tags_around_actions)
options = options.except(
:log_query_tags_around_actions,
:permit_all_parameters,
:action_on_unpermitted_parameters,
:always_permitted_parameters
)
ActiveSupport.on_load(:action_controller) do
include app.routes.mounted_helpers

View File

@ -16,7 +16,7 @@ module ActiveJob
initializer "active_job.custom_serializers" do |app|
config.after_initialize do
custom_serializers = app.config.active_job.delete(:custom_serializers)
custom_serializers = app.config.active_job.custom_serializers
ActiveJob::Serializers.add_serializers custom_serializers
end
end
@ -26,7 +26,10 @@ module ActiveJob
options.queue_adapter ||= :async
# Configs used in other initializers
options = options.except(:log_query_tags_around_perform)
options = options.except(
:log_query_tags_around_perform,
:custom_serializers
)
ActiveSupport.on_load(:active_job) do
options.each do |k, v|