Skip to content

Commit

Permalink
YAML.safe_load_file to allow the use of aliases
Browse files Browse the repository at this point in the history
with Psych 3.2.1+ (i.e. Ruby 3.1+)
  • Loading branch information
mishina2228 committed Jan 17, 2022
1 parent 2100316 commit 7efb0d3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class ActiveRecord::ConnectionAdapters::Mysql2Adapter
ActiveRecord::Base.logger.level = Logger::DEBUG

if ENV['AR_VERSION'].to_f >= 6.0
yaml_config = YAML.load_file(test_dir.join("database.yml"))[adapter]
yaml_config = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.2.1')
YAML.safe_load_file(test_dir.join("database.yml"), aliases: true)[adapter]
else
YAML.load_file(test_dir.join("database.yml"))[adapter]
end
config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", adapter, yaml_config)
ActiveRecord::Base.configurations.configurations << config
else
Expand Down

0 comments on commit 7efb0d3

Please sign in to comment.