FIX: tweak restorer spec to make it stableish (#8300)
This commit is contained in:
parent
e3b7f07916
commit
5ad0dd0c23
|
@ -3,7 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
# Causes flakiness
|
||||
xdescribe BackupRestore::Restorer do
|
||||
describe BackupRestore::Restorer do
|
||||
it 'detects which pg_dump output is restorable to different schemas' do
|
||||
{
|
||||
"9.6.7" => true,
|
||||
|
@ -106,22 +106,21 @@ xdescribe BackupRestore::Restorer do
|
|||
let!(:admin) { Fabricate(:admin) }
|
||||
before do
|
||||
SiteSetting.allow_restore = true
|
||||
@restore_path = File.join(Rails.root, 'public', 'backups', RailsMultisite::ConnectionManagement.current_db)
|
||||
described_class.any_instance.stubs(ensure_we_have_a_filename: true)
|
||||
described_class.any_instance.stubs(initialize_state: true)
|
||||
end
|
||||
|
||||
after do
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
Rails.configuration.multisite = false
|
||||
RailsMultisite::ConnectionManagement.clear_settings!
|
||||
ActiveRecord::Base.establish_connection
|
||||
SiteSetting.allow_restore = false
|
||||
described_class.any_instance.unstub(:ensure_we_have_a_filename)
|
||||
described_class.any_instance.unstub(:initialize_state)
|
||||
end
|
||||
|
||||
let(:conn) { RailsMultisite::ConnectionManagement }
|
||||
let(:restorer) { described_class.new(admin.id) }
|
||||
|
||||
it 'correctly reconnects to database' do
|
||||
it 'correctly reconnects to database', type: :multisite do
|
||||
restorer.instance_variable_set(:@current_db, 'second')
|
||||
conn.config_filename = "spec/fixtures/multisite/two_dbs.yml"
|
||||
conn.establish_connection(db: 'second')
|
||||
expect(RailsMultisite::ConnectionManagement.current_db).to eq('second')
|
||||
ActiveRecord::Base.connection_pool.spec.config[:db_key] = "incorrect_db"
|
||||
|
@ -129,7 +128,7 @@ xdescribe BackupRestore::Restorer do
|
|||
expect(RailsMultisite::ConnectionManagement.current_db).to eq('second')
|
||||
end
|
||||
|
||||
it 'it is not erroring for non multisite' do
|
||||
it 'it is not erroring for non multisite', type: :multisite do
|
||||
RailsMultisite::ConnectionManagement::clear_settings!
|
||||
expect { restorer.send(:reconnect_database) }.not_to raise_error
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue