DEV: Improve multisite testing (#14884)

This commit adds the RailsMultisite middleware in test mode when Rails.configuration.multisite is true. This allows for much more realistic integration testing. The `multisite_spec.rb` file is rewritten to avoid needing to simulate a middleware stack.
This commit is contained in:
David Taylor
2021-11-11 16:44:58 +00:00
committed by GitHub
parent a3814b1e56
commit 13fdc979a8
4 changed files with 40 additions and 54 deletions

View File

@@ -291,6 +291,10 @@ RSpec.configure do |config|
DB.test_transaction = ActiveRecord::Base.connection.current_transaction
end
# Match the request hostname to the value in `database.yml`
config.before(:all, type: [:request, :multisite]) { host! "test.localhost" }
config.before(:each, type: [:request, :multisite]) { host! "test.localhost" }
config.before(:each, type: :multisite) do
Rails.configuration.multisite = true # rubocop:disable Discourse/NoDirectMultisiteManipulation