FIX: Restore for non-multisite is not raising an error on reconnect step (#8237)
That commit introduced a bug to the system: f69dacf979
Restore works fine for multisite, however, stopped working for non-multisite.
Reason for that was that `establish_connection` method got a check if the multisite instance is available:
```
def self.instance
@instance
end
def self.establish_connection(opts)
@instance.establish_connection(opts) if @instance
end
```
However, the reload method don't have that check
```
def self.reload
@instance = new(instance.config_filename)
end
```
To solve it, let's ensure we are in a multisite environment before call reload
This commit is contained in:
parent
cfe26eb301
commit
f530378df3
|
@ -404,7 +404,7 @@ module BackupRestore
|
||||||
|
|
||||||
def reconnect_database
|
def reconnect_database
|
||||||
log "Reconnecting to the database..."
|
log "Reconnecting to the database..."
|
||||||
RailsMultisite::ConnectionManagement::reload
|
RailsMultisite::ConnectionManagement::reload if RailsMultisite::ConnectionManagement::instance
|
||||||
RailsMultisite::ConnectionManagement::establish_connection(db: @current_db)
|
RailsMultisite::ConnectionManagement::establish_connection(db: @current_db)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -124,5 +124,10 @@ describe BackupRestore::Restorer do
|
||||||
restorer.send(:reconnect_database)
|
restorer.send(:reconnect_database)
|
||||||
expect(RailsMultisite::ConnectionManagement.current_db).to eq('second')
|
expect(RailsMultisite::ConnectionManagement.current_db).to eq('second')
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue