diff --git a/lib/backup_restore/restorer.rb b/lib/backup_restore/restorer.rb index 1efceafd128..8d902da8a14 100644 --- a/lib/backup_restore/restorer.rb +++ b/lib/backup_restore/restorer.rb @@ -404,7 +404,7 @@ module BackupRestore def reconnect_database log "Reconnecting to the database..." - RailsMultisite::ConnectionManagement::reload + RailsMultisite::ConnectionManagement::reload if RailsMultisite::ConnectionManagement::instance RailsMultisite::ConnectionManagement::establish_connection(db: @current_db) end diff --git a/spec/lib/backup_restore/restorer_spec.rb b/spec/lib/backup_restore/restorer_spec.rb index 8bd311580f4..4eac39bdd85 100644 --- a/spec/lib/backup_restore/restorer_spec.rb +++ b/spec/lib/backup_restore/restorer_spec.rb @@ -124,5 +124,10 @@ describe BackupRestore::Restorer do restorer.send(:reconnect_database) expect(RailsMultisite::ConnectionManagement.current_db).to eq('second') end + + it 'it is not erroring for non multisite' do + RailsMultisite::ConnectionManagement::clear_settings! + expect{ restorer.send(:reconnect_database) }.not_to raise_error + end end end