Only seed tenants when necessary in tests
On my machine, seeding a tenant takes about one second, so skipping this action when it isn't necessary makes tests creating tenants faster (although creating a tenant still takes about 3-4 seconds on my machine).
This commit is contained in:
@@ -13,7 +13,7 @@ require "apartment/elevators/generic"
|
|||||||
#
|
#
|
||||||
Apartment.configure do |config|
|
Apartment.configure do |config|
|
||||||
ENV["IGNORE_EMPTY_TENANTS"] = "true" if Rails.env.test? || Rails.application.config.multitenancy.blank?
|
ENV["IGNORE_EMPTY_TENANTS"] = "true" if Rails.env.test? || Rails.application.config.multitenancy.blank?
|
||||||
config.seed_after_create = true
|
config.seed_after_create = !Rails.env.test?
|
||||||
|
|
||||||
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
|
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
|
||||||
# A typical example would be a Customer or Tenant model that stores each Tenant's information.
|
# A typical example would be a Customer or Tenant model that stores each Tenant's information.
|
||||||
|
|||||||
@@ -80,15 +80,18 @@ describe "rake sitemap:create", type: :system do
|
|||||||
create(:tenant, schema: "debates")
|
create(:tenant, schema: "debates")
|
||||||
create(:tenant, schema: "proposals")
|
create(:tenant, schema: "proposals")
|
||||||
|
|
||||||
|
Setting["process.budgets"] = true
|
||||||
Setting["process.debates"] = false
|
Setting["process.debates"] = false
|
||||||
Setting["process.proposals"] = false
|
Setting["process.proposals"] = false
|
||||||
|
|
||||||
Tenant.switch("debates") do
|
Tenant.switch("debates") do
|
||||||
|
Setting["process.debates"] = true
|
||||||
Setting["process.budgets"] = false
|
Setting["process.budgets"] = false
|
||||||
Setting["process.proposals"] = false
|
Setting["process.proposals"] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
Tenant.switch("proposals") do
|
Tenant.switch("proposals") do
|
||||||
|
Setting["process.proposals"] = true
|
||||||
Setting["process.budgets"] = false
|
Setting["process.budgets"] = false
|
||||||
Setting["process.debates"] = false
|
Setting["process.debates"] = false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -117,6 +117,14 @@ RSpec.configure do |config|
|
|||||||
Delayed::Worker.delay_jobs = false
|
Delayed::Worker.delay_jobs = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.before(:each, :seed_tenants) do
|
||||||
|
Apartment.seed_after_create = true
|
||||||
|
end
|
||||||
|
|
||||||
|
config.after(:each, :seed_tenants) do
|
||||||
|
Apartment.seed_after_create = false
|
||||||
|
end
|
||||||
|
|
||||||
config.before(:each, :small_window) do
|
config.before(:each, :small_window) do
|
||||||
@window_size = Capybara.current_window.size
|
@window_size = Capybara.current_window.size
|
||||||
Capybara.current_window.resize_to(639, 479)
|
Capybara.current_window.resize_to(639, 479)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "Tenants", :admin do
|
describe "Tenants", :admin, :seed_tenants do
|
||||||
before { allow(Tenant).to receive(:default_host).and_return("localhost") }
|
before { allow(Tenant).to receive(:default_host).and_return("localhost") }
|
||||||
|
|
||||||
scenario "Create" do
|
scenario "Create" do
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "Multitenancy" do
|
describe "Multitenancy", :seed_tenants do
|
||||||
before do
|
before do
|
||||||
create(:tenant, schema: "mars")
|
create(:tenant, schema: "mars")
|
||||||
create(:tenant, schema: "venus")
|
create(:tenant, schema: "venus")
|
||||||
|
|||||||
Reference in New Issue
Block a user