Set notes to null when assigning allocation; ref #2553

This commit is contained in:
Dane Everitt 2020-10-19 21:08:40 -07:00
parent 1f5e0c0334
commit 26de4493dd
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 3 additions and 2 deletions

View File

@ -115,7 +115,7 @@ class BuildModificationService
// one to reset the default allocation to.
$freshlyAllocated = $query->pluck('id')->first();
$query->update(['server_id' => $server->id]);
$query->update(['server_id' => $server->id, 'notes' => null]);
}
if (! empty($data['remove_allocations'])) {

View File

@ -39,7 +39,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
$server2 = $this->createServerModel();
/** @var \Pterodactyl\Models\Allocation[] $allocations */
$allocations = factory(Allocation::class)->times(4)->create(['node_id' => $server->node_id]);
$allocations = factory(Allocation::class)->times(4)->create(['node_id' => $server->node_id, 'notes' => 'Random notes']);
$initialAllocationId = $server->allocation_id;
$allocations[0]->update(['server_id' => $server->id, 'notes' => 'Test notes']);
@ -66,6 +66,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
// Only one allocation should exist for this server now.
$this->assertCount(1, $response->allocations);
$this->assertSame($allocations[1]->id, $response->allocation_id);
$this->assertNull($response->allocation->notes);
// These two allocations should not have been touched.
$this->assertDatabaseHas('allocations', ['id' => $allocations[2]->id, 'server_id' => $server2->id]);