DEV: improve db:create to catch all cases

- No RAILS_ENV - create multisite / dev / test
- `test` RAILS_ENV - create multisite / test
This commit is contained in:
Sam Saffron 2019-06-14 15:44:07 +10:00
parent befb074c98
commit ecb2fd8222

View File

@ -13,6 +13,10 @@ module MultisiteTestHelpers
def self.load_multisite?
Rails.env.test? && !ENV["RAILS_DB"] && !ENV["SKIP_MULTISITE"]
end
def self.create_multisite?
(ENV["RAILS_ENV"] == "test" || !ENV["RAILS_ENV"]) && !ENV["RAILS_DB"] && !ENV["SKIP_MULTISITE"]
end
end
task 'db:environment:set' => [:load_config] do |_, args|
@ -27,7 +31,7 @@ task 'db:force_skip_persist' do
end
task 'db:create' => [:load_config] do |_, args|
if !ENV['RAILS_ENV']
if MultisiteTestHelpers.create_multisite?
system("RAILS_ENV=test RAILS_DB=discourse_test_multisite rake db:create")
end
end
@ -39,8 +43,8 @@ begin
end
task 'db:drop' => [:load_config] do |_, args|
if MultisiteTestHelpers.load_multisite?
system("RAILS_DB=discourse_test_multisite rake db:drop")
if MultisiteTestHelpers.create_multisite?
system("RAILS_DB=discourse_test_multisite RAILS_ENV=test rake db:drop")
end
end