DEV: Clear connections after multisite specs.
This commit is contained in:
parent
244948497a
commit
85620abb71
|
@ -1,17 +1,8 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Multisite SiteSettings' do
|
RSpec.describe 'Multisite SiteSettings', type: :multisite do
|
||||||
let(:conn) { RailsMultisite::ConnectionManagement }
|
let(:conn) { RailsMultisite::ConnectionManagement }
|
||||||
|
|
||||||
before do
|
|
||||||
conn.config_filename = "spec/fixtures/multisite/two_dbs.yml"
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
conn.clear_settings!
|
|
||||||
ActiveRecord::Base.establish_connection
|
|
||||||
end
|
|
||||||
|
|
||||||
def cache(name, namespace: true)
|
def cache(name, namespace: true)
|
||||||
DistributedCache.new(name, namespace: namespace)
|
DistributedCache.new(name, namespace: namespace)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe "Running Sidekiq Jobs in Multisite" do
|
RSpec.describe "Running Sidekiq Jobs in Multisite", type: :multisite do
|
||||||
let(:conn) { RailsMultisite::ConnectionManagement }
|
let(:conn) { RailsMultisite::ConnectionManagement }
|
||||||
|
|
||||||
before do
|
|
||||||
conn.config_filename = "spec/fixtures/multisite/two_dbs.yml"
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
conn.clear_settings!
|
|
||||||
ActiveRecord::Base.establish_connection
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should revert back to the default connection' do
|
it 'should revert back to the default connection' do
|
||||||
expect(RailsMultisite::ConnectionManagement.current_db)
|
expect do
|
||||||
.to eq('default')
|
Jobs::DestroyOldDeletionStubs.new.perform({})
|
||||||
|
end.to_not change { RailsMultisite::ConnectionManagement.current_db }
|
||||||
Jobs::DestroyOldDeletionStubs.new.perform({})
|
|
||||||
|
|
||||||
expect(RailsMultisite::ConnectionManagement.current_db)
|
|
||||||
.to eq('default')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe 'Multisite SiteSettings' do
|
RSpec.describe 'Multisite SiteSettings', type: :multisite do
|
||||||
let(:conn) { RailsMultisite::ConnectionManagement }
|
let(:conn) { RailsMultisite::ConnectionManagement }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@original_provider = SiteSetting.provider
|
@original_provider = SiteSetting.provider
|
||||||
SiteSetting.provider = SiteSettings::DbProvider.new(SiteSetting)
|
SiteSetting.provider = SiteSettings::DbProvider.new(SiteSetting)
|
||||||
conn.config_filename = "spec/fixtures/multisite/two_dbs.yml"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -14,9 +13,7 @@ RSpec.describe 'Multisite SiteSettings' do
|
||||||
conn.with_connection(db) { SiteSetting.where(name: 'default_locale').destroy_all }
|
conn.with_connection(db) { SiteSetting.where(name: 'default_locale').destroy_all }
|
||||||
end
|
end
|
||||||
|
|
||||||
conn.clear_settings!
|
|
||||||
SiteSetting.provider = @original_provider
|
SiteSetting.provider = @original_provider
|
||||||
ActiveRecord::Base.establish_connection
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#default_locale' do
|
describe '#default_locale' do
|
||||||
|
|
|
@ -175,6 +175,17 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.before(:each, type: :multisite) do
|
||||||
|
RailsMultisite::ConnectionManagement.config_filename =
|
||||||
|
"spec/fixtures/multisite/two_dbs.yml"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.after(:each, type: :multisite) do
|
||||||
|
RailsMultisite::ConnectionManagement.clear_settings!
|
||||||
|
ActiveRecord::Base.clear_active_connections!
|
||||||
|
ActiveRecord::Base.establish_connection
|
||||||
|
end
|
||||||
|
|
||||||
class TestCurrentUserProvider < Auth::DefaultCurrentUserProvider
|
class TestCurrentUserProvider < Auth::DefaultCurrentUserProvider
|
||||||
def log_on_user(user, session, cookies)
|
def log_on_user(user, session, cookies)
|
||||||
session[:current_user_id] = user.id
|
session[:current_user_id] = user.id
|
||||||
|
|
Loading…
Reference in New Issue