Skip to content

Commit 21f8064

Browse files
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 <[email protected]>
1 parent 0fa4405 commit 21f8064

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

railties/lib/rails/test_unit/testing.rake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ namespace :test do
2424
task run: %w[test]
2525

2626
desc "Run tests quickly, but also reset db"
27-
task db: %w[db:test:prepare test]
27+
task :db do
28+
success = system({ "RAILS_ENV" => ENV.fetch("RAILS_ENV", "test") }, "rake", "db:test:prepare", "test")
29+
success || exit(false)
30+
end
2831

2932
["models", "helpers", "channels", "controllers", "mailers", "integration", "jobs", "mailboxes"].each do |name|
3033
task name => "test:prepare" do

0 commit comments

Comments
 (0)