Use DATABASE_URL instead of temp database.yml for multi-db tests

Replace the RAILS_DATABASE_YML / Dir.mktmpdir approach with DATABASE_URL:
- Read database config via Rails.application.config.database_configuration
  instead of manually parsing YAML+ERB
- Build a DATABASE_URL from each test config and pass it to subprocesses;
  Rails merges it on top of the test: entry — no temp files needed
- Remove non_test_configs, Dir.mktmpdir, and the require yaml/erb/tmpdir
- Remove RAILS_DATABASE_YML override from config/application.rb(.dist)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 11:47:35 +00:00
parent 3e0f27b357
commit badb4b336c
2 changed files with 34 additions and 32 deletions

View File

@@ -20,10 +20,6 @@ Bundler.require(*Rails.groups)
module FixinMe
class Application < Rails::Application
# Allow RAILS_DATABASE_YML to override the database config file path.
# Used by the multi-database test runner (lib/tasks/test_databases.rake).
config.paths['config/database'] = [ENV['RAILS_DATABASE_YML']] if ENV['RAILS_DATABASE_YML']
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0