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

Add support for ruby version 3.1 and psych 4.0 #76

Closed eikes closed 2 years ago

eikes commented 2 years ago

Ruby 3.1 and above ships with Psych 4.0. Psych throws a Psych::BadAlias: Unknown alias: default error when it loads a database.yml which uses YAML inheritance such as the following:

default: &default
  adapter: sqlite3

inherited:
  <<: *default
  database: example.sqlite3

We implement the the same pattern as ActiveSupport::ConfigurationFile to circumvent this problem: use YAML.unsafe_load when it is available.

cesarjr commented 2 years ago

Wow! It's gonna help me a lot. Thank you.

etagwerker commented 2 years ago

@eikes Thanks for submitting this! I ended up merging #64 which is similar to your changes.

eis-ioki commented 1 year ago

It's nice to be able to use ruby 3.1. But This PR didn't fix the rails 7.1 issue. So I opened another one for that:

https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/78