DatabaseCleaner / database_cleaner-active_record

Strategies for cleaning databases using ActiveRecord. Can be used to ensure a clean state for testing.
MIT License
64 stars 63 forks source link

Address deprecation of `ActiveRecord::Base.connection` in Rails 7.2 #102

Closed joshuay03 closed 5 months ago

joshuay03 commented 7 months ago

Context: https://github.com/rails/rails/pull/51349

~Ensures that applications using config.active_record.permanent_connection_checkout = :disallowed are supported from Rails 7.2 onwards.~ This was what this PR started as, but this would require a significant API change looking at how the #start and #clean APIs are used.

Addresses the deprecation of ActiveRecord::Base.connection in favour of ActiveRecord::Base.lease_connection as of Rails 7.2.

There's one more usage of .connection but that seems to be getting removed in #101.

ghiculescu commented 5 months ago

I think this usage also needs to be updated: https://github.com/DatabaseCleaner/database_cleaner-active_record/blob/aafa5b273bebf9432353fc8a65ce1e8b449cecb0/lib/database_cleaner/active_record/truncation.rb#L33

Otherwise you get a "Called deprecated ActiveRecord::Base.connection method." deprecation warning.

joshuay03 commented 5 months ago

@ghiculescu Addressed 👍🏽