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. // one to reset the default allocation to.
$freshlyAllocated = $query->pluck('id')->first(); $freshlyAllocated = $query->pluck('id')->first();
$query->update(['server_id' => $server->id]); $query->update(['server_id' => $server->id, 'notes' => null]);
} }
if (! empty($data['remove_allocations'])) { if (! empty($data['remove_allocations'])) {

View file

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