DEV: Stablize the multisite tests.
SiteSettingExtension triggers message bus which re-establishes a DB connection in `SiteSettingExtension#process_message`. That happens concurrently and a test that requires a connection to the db will fail when the reconnection is happening.
This commit is contained in:
parent
037776881b
commit
51b19e945c
|
@ -301,22 +301,22 @@ module SiteSettingExtension
|
|||
|
||||
unless @subscribed
|
||||
MessageBus.subscribe("/site_settings") do |message|
|
||||
process_message(message)
|
||||
if message.data["process"] != process_id
|
||||
process_message(message)
|
||||
end
|
||||
end
|
||||
|
||||
@subscribed = true
|
||||
end
|
||||
end
|
||||
|
||||
def process_message(message)
|
||||
data = message.data
|
||||
if data["process"] != process_id
|
||||
begin
|
||||
@last_message_processed = message.global_id
|
||||
MessageBus.on_connect.call(message.site_id)
|
||||
refresh!
|
||||
ensure
|
||||
MessageBus.on_disconnect.call(message.site_id)
|
||||
end
|
||||
begin
|
||||
@last_message_processed = message.global_id
|
||||
MessageBus.on_connect.call(message.site_id)
|
||||
refresh!
|
||||
ensure
|
||||
MessageBus.on_disconnect.call(message.site_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -42,16 +42,6 @@ describe SiteSettingExtension do
|
|||
SiteSettings::LocalProcessProvider.new
|
||||
end
|
||||
|
||||
def new_settings(provider)
|
||||
# we want to avoid leaking a big pile of MessageBus subscriptions here (1 per class)
|
||||
# so we set listen_for_changes to false
|
||||
Class.new do
|
||||
extend SiteSettingExtension
|
||||
self.listen_for_changes = false
|
||||
self.provider = provider
|
||||
end
|
||||
end
|
||||
|
||||
let :settings do
|
||||
new_settings(provider_local)
|
||||
end
|
||||
|
|
|
@ -14,14 +14,6 @@ describe SiteSettings::DefaultsProvider do
|
|||
MessageBus.on
|
||||
end
|
||||
|
||||
def new_settings(provider)
|
||||
Class.new do
|
||||
extend SiteSettingExtension
|
||||
self.listen_for_changes = false
|
||||
self.provider = provider
|
||||
end
|
||||
end
|
||||
|
||||
let(:settings) do
|
||||
new_settings(provider_local)
|
||||
end
|
||||
|
|
|
@ -6,13 +6,6 @@ describe SiteSettings::TypeSupervisor do
|
|||
SiteSettings::LocalProcessProvider.new
|
||||
end
|
||||
|
||||
def new_settings(provider)
|
||||
Class.new do
|
||||
extend SiteSettingExtension
|
||||
self.provider = provider
|
||||
end
|
||||
end
|
||||
|
||||
let :settings do
|
||||
new_settings(provider_local)
|
||||
end
|
||||
|
|
|
@ -70,6 +70,7 @@ RSpec.configure do |config|
|
|||
config.include MessageBus
|
||||
config.include RSpecHtmlMatchers
|
||||
config.include IntegrationHelpers, type: :request
|
||||
config.include SiteSettingsHelpers
|
||||
config.mock_framework = :mocha
|
||||
config.order = 'random'
|
||||
config.infer_spec_type_from_file_location!
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
module SiteSettingsHelpers
|
||||
def new_settings(provider)
|
||||
Class.new do
|
||||
extend SiteSettingExtension
|
||||
# we want to avoid leaking a big pile of MessageBus subscriptions here (1 per class)
|
||||
# so we set listen_for_changes to false
|
||||
self.listen_for_changes = false
|
||||
self.provider = provider
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue