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:
parent
0fa44051c8
commit
21f8064781
1 changed files with 4 additions and 1 deletions
|
@ -24,7 +24,10 @@ namespace :test do
|
||||||
task run: %w[test]
|
task run: %w[test]
|
||||||
|
|
||||||
desc "Run tests quickly, but also reset db"
|
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|
|
["models", "helpers", "channels", "controllers", "mailers", "integration", "jobs", "mailboxes"].each do |name|
|
||||||
task name => "test:prepare" do
|
task name => "test:prepare" do
|
||||||
|
|
Loading…
Reference in a new issue