aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/isolation
diff options
context:
space:
mode:
authorWojciech Wnętrzak <w.wnetrzak@gmail.com>2019-06-03 15:55:37 +0200
committerWojciech Wnętrzak <w.wnetrzak@gmail.com>2019-06-05 12:17:02 +0200
commit87796b3c8120becf583529756cbe5f36b4a3132c (patch)
tree5264aa28db489e93081f1258e11b87d661fc612d /railties/test/isolation
parent35a0fba187dc6a09d9f61336152158da238da444 (diff)
downloadrails-87796b3c8120becf583529756cbe5f36b4a3132c.tar.gz
rails-87796b3c8120becf583529756cbe5f36b4a3132c.tar.bz2
rails-87796b3c8120becf583529756cbe5f36b4a3132c.zip
Fixed db:prepare task for multiple databases.
When one database existed already, but not the other, during setup of missing one, existing database was wiped out.
Diffstat (limited to 'railties/test/isolation')
-rw-r--r--railties/test/isolation/abstract_unit.rb42
1 files changed, 30 insertions, 12 deletions
diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb
index fab704944b..0fe62df8ba 100644
--- a/railties/test/isolation/abstract_unit.rb
+++ b/railties/test/isolation/abstract_unit.rb
@@ -448,18 +448,36 @@ module TestHelpers
$:.reject! { |path| path =~ %r'/(#{to_remove.join('|')})/' }
end
- def use_postgresql
- File.open("#{app_path}/config/database.yml", "w") do |f|
- f.puts <<-YAML
- default: &default
- adapter: postgresql
- pool: 5
- database: railties_test
- development:
- <<: *default
- test:
- <<: *default
- YAML
+ def use_postgresql(multi_db: false)
+ if multi_db
+ File.open("#{app_path}/config/database.yml", "w") do |f|
+ f.puts <<-YAML
+ default: &default
+ adapter: postgresql
+ pool: 5
+ development:
+ primary:
+ <<: *default
+ database: railties_test
+ animals:
+ <<: *default
+ database: railties_animals_test
+ migrations_paths: db/animals_migrate
+ YAML
+ end
+ else
+ File.open("#{app_path}/config/database.yml", "w") do |f|
+ f.puts <<-YAML
+ default: &default
+ adapter: postgresql
+ pool: 5
+ database: railties_test
+ development:
+ <<: *default
+ test:
+ <<: *default
+ YAML
+ end
end
end
end