mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:02:46 +08:00
DEV: Make setting up of multisite DB in test env clearer.
This commit is contained in:
parent
600313373b
commit
8e5e5d7d35
|
@ -19,7 +19,7 @@ development:
|
|||
test:
|
||||
prepared_statements: false
|
||||
adapter: postgresql
|
||||
database: "discourse_test<%= ENV['MULTISITE'] ? '_' + ENV['MULTISITE'] : '' %>"
|
||||
database: <%= ENV["RAILS_DB"] ? ENV["RAILS_DB"] : "discourse_test" %>
|
||||
min_messages: warning
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
|
|
|
@ -7,32 +7,38 @@ task 'set_locale' do
|
|||
end
|
||||
end
|
||||
|
||||
task 'db:environment:set', [:multisite] => [:load_config] do |_, args|
|
||||
if Rails.env.test? && !args[:multisite]
|
||||
system("MULTISITE=multisite rails db:environment:set['true'] RAILS_ENV=test")
|
||||
module MultisiteTestHelpers
|
||||
def self.load_multisite?
|
||||
Rails.env.test? && !ENV["RAILS_DB"] && !ENV["SKIP_MULTISITE"]
|
||||
end
|
||||
end
|
||||
|
||||
task 'db:create', [:multisite] => [:load_config] do |_, args|
|
||||
if Rails.env.test? && !args[:multisite]
|
||||
system("MULTISITE=multisite rails db:create['true']")
|
||||
task 'db:environment:set' => [:load_config] do |_, args|
|
||||
if MultisiteTestHelpers.load_multisite?
|
||||
system("RAILS_ENV=test RAILS_DB=discourse_test_multisite rake db:environment:set")
|
||||
end
|
||||
end
|
||||
|
||||
task 'db:drop', [:multisite] => [:load_config] do |_, args|
|
||||
if Rails.env.test? && !args[:multisite]
|
||||
system("MULTISITE=multisite rails db:drop['true']")
|
||||
task 'db:create' => [:load_config] do |_, args|
|
||||
if MultisiteTestHelpers.load_multisite?
|
||||
system("RAILS_DB=discourse_test_multisite rake db:create")
|
||||
end
|
||||
end
|
||||
|
||||
# we need to run seed_fu every time we run rails db:migrate
|
||||
task 'db:migrate', [:multisite] => ['environment', 'set_locale'] do |_, args|
|
||||
task 'db:drop' => [:load_config] do |_, args|
|
||||
if MultisiteTestHelpers.load_multisite?
|
||||
system("RAILS_DB=discourse_test_multisite rake db:drop")
|
||||
end
|
||||
end
|
||||
|
||||
# we need to run seed_fu every time we run rake db:migrate
|
||||
task 'db:migrate' => ['environment', 'set_locale'] do |_, args|
|
||||
SeedFu.seed(DiscoursePluginRegistry.seed_paths)
|
||||
|
||||
if Rails.env.test? && !args[:multisite] && !ENV["SKIP_MULTISITE"]
|
||||
system("rails db:schema:dump")
|
||||
system("MULTISITE=multisite rails db:schema:load")
|
||||
system("RAILS_DB=discourse_test_multisite rails db:migrate['multisite']")
|
||||
if MultisiteTestHelpers.load_multisite?
|
||||
system("rake db:schema:dump")
|
||||
system("RAILS_DB=discourse_test_multisite rake db:schema:load")
|
||||
system("RAILS_DB=discourse_test_multisite rake db:migrate")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -100,6 +100,9 @@ task 'docker:test' do
|
|||
@pg_pid = Process.spawn("#{@postgres_bin}postmaster -D tmp/test_data/pg")
|
||||
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
# this shaves all the creation of the multisite db off
|
||||
# for js tests
|
||||
ENV["SKIP_MULTISITE"] = "1" if ENV["JS_ONLY"]
|
||||
|
||||
@good &&= run_or_fail("bundle exec rake db:create")
|
||||
|
||||
|
@ -107,10 +110,6 @@ task 'docker:test' do
|
|||
@good &&= run_or_fail("bundle exec rake plugin:install_all_official")
|
||||
end
|
||||
|
||||
# this shaves all the creation of the multisite db off
|
||||
# for js tests
|
||||
ENV["SKIP_MULTISITE"] = "1" if ENV["JS_ONLY"]
|
||||
|
||||
if ENV["SKIP_PLUGINS"]
|
||||
@good &&= run_or_fail("bundle exec rake db:migrate")
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user