1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix rake test:db loading in development

Not setting the test environment for test tasks caused the test:db task
to establish connection with the development environment.

This fixes it by running the prerequisite rake tasks in a process with
RAILS_ENV set to test.

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
This commit is contained in:
Étienne Barrié 2021-02-02 15:18:53 -05:00
parent 0fa44051c8
commit 21f8064781

View file

@ -24,7 +24,10 @@ namespace :test do
task run: %w[test]
desc "Run tests quickly, but also reset db"
task db: %w[db:test:prepare test]
task :db do
success = system({ "RAILS_ENV" => ENV.fetch("RAILS_ENV", "test") }, "rake", "db:test:prepare", "test")
success || exit(false)
end
["models", "helpers", "channels", "controllers", "mailers", "integration", "jobs", "mailboxes"].each do |name|
task name => "test:prepare" do