From 4fca1eaaea8ee9e29c5818aa7d74773e4a413828 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Fri, 20 Jan 2023 11:41:21 +0100 Subject: [PATCH] Fix deprecation warning It set Rails.application.config.active_record.legacy_connection_handling to false, as would Rails 6.1 default do. This removes a deprecation warning showing up each time tests are run, and enables granular connection swapping (which we do not use currently, but this may change in the future). --- config/application.rb | 8 ++++++++ config/initializers/new_framework_defaults_6_1.rb | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index 40e0a24d38..d2635a094c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -64,6 +64,14 @@ module OpenProject # files. See https://community.openproject.org/wp/45463 for details. # config.load_defaults 5.0 + # Use new connection handling API. For most applications this won't have any + # effect. For applications using multiple databases, this new API provides + # support for granular connection swapping. + # It has to be done here to prevent having the deprecation warning + # displayed. This line and its comment can safely be removed + # once `config.load_defaults 6.1` is used. + config.active_record.legacy_connection_handling = false + # Sets up logging for STDOUT and configures the default logger formatter # so that all environments receive level and timestamp information # diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb index 4ce326bc5a..728e9dcf26 100644 --- a/config/initializers/new_framework_defaults_6_1.rb +++ b/config/initializers/new_framework_defaults_6_1.rb @@ -57,8 +57,8 @@ # Use new connection handling API. For most applications this won't have any # effect. For applications using multiple databases, this new API provides # support for granular connection swapping. -# Previous versions had false. Rails 6.1+ default is true. -# Rails.application.config.active_record.legacy_connection_handling = false +# Previous versions had true. Rails 6.1+ default is false. +Rails.application.config.active_record.legacy_connection_handling = false # https://guides.rubyonrails.org/configuring.html#config-action-view-form-with-generates-remote-forms # Make `form_with` generate non-remote forms by default.