Closed caius closed 8 months ago
Testing this in the main app locally. Changing config/environments/development.rb
and then outputting stuff from Rails Runner. We're looking specifically at:
ActiveSupport::Deprecation.behavior
ActiveSupport::Deprecation._instance.behavior
Rails.application.deprecators.instance_variable_get(:@options)[:behavior]
✅ With config.active_support.deprecation = :log
we get [:log
, our proc] returned in all three places.
✅ With # config.active_support.deprecation
(ie, commented out), we get [our proc] returned from all three places.
✅ With config.active_support.deprecation = [:log, :notify]
we get [:log
, :notify
, our proc] from all three places.
Extracted the Railtie out to its own file to make it easier to add a test for it. Mocked rails out rather than try and pull a version of it in and deal with it.
What?
Rakefile
for Ruby 3.3.0OasAgent::Railtie
to own file & add test for itWhy?
Instead of trying to attach ourselves after the rails configuration has setup deprecation behaviour and take care of everything in every version of rails that reads that config setting, instead lets have our initialiser run just before Rails sets up deprecation behaviour in the app during startup so we get Rails to do the heavy lifting for us. Rails has allowed multiple behaviours to be set through this config variable since it was introduced in Rails 3.0.
This looks like a more "railsy" way to integrate, and has the nice advantage we don't need to track what Rails is doing, as long as it supports
config.active_support.deprecation
it'll do the right thing. The new deprecators collection in Rails 7.1+ still gets populated from this config option for example.