Fix data integrity exception thrown when attempting to store updated server egg variables

This commit is contained in:
Dane Everitt 2018-03-10 13:55:24 -06:00
parent 08a112f027
commit abd2a42471
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 10 additions and 5 deletions

View File

@ -10,6 +10,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* Fixes improper behavior when marking an egg as copying the configuration from another.
* Debug bar is only checked when the app is set to debug mode in the API session handler, rather than when it is in local mode to match the plugin settings.
* Added validation to port allocations to prevent allocation of restricted or invalid ports.
* Fix data integrity exception thrown when attempting to store updated server egg variables.
### Changed
* Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline.

View File

@ -105,7 +105,7 @@ class StartupModificationService
'server_id' => $server->id,
'variable_id' => $result->id,
], [
'variable_value' => $result->value,
'variable_value' => $result->value ?? '',
]);
});
}

View File

@ -121,14 +121,18 @@ class StartupModificationServiceTest extends TestCase
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
$this->validatorService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_ADMIN)->once()->andReturnNull();
$this->validatorService->shouldReceive('handle')->with(456, ['test' => 'abcd1234'])->once()->andReturn(
collect([(object) ['id' => 1, 'value' => 'stored-value']])
collect([(object) ['id' => 1, 'value' => 'stored-value'], (object) ['id' => 2, 'value' => null]])
);
$this->serverVariableRepository->shouldReceive('withoutFreshModel')->withNoArgs()->once()->andReturnSelf();
$this->serverVariableRepository->shouldReceive('updateOrCreate')->with([
$this->serverVariableRepository->shouldReceive('withoutFreshModel->updateOrCreate')->once()->with([
'server_id' => $model->id,
'variable_id' => 1,
], ['variable_value' => 'stored-value'])->once()->andReturnNull();
], ['variable_value' => 'stored-value'])->andReturnNull();
$this->serverVariableRepository->shouldReceive('withoutFreshModel->updateOrCreate')->once()->with([
'server_id' => $model->id,
'variable_id' => 2,
], ['variable_value' => ''])->andReturnNull();
$this->eggRepository->shouldReceive('setColumns->find')->once()->with($eggModel->id)->andReturn($eggModel);