From 26de4493dda2a7ba65a0076f02c187450805ca80 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 19 Oct 2020 21:08:40 -0700 Subject: [PATCH] Set notes to null when assigning allocation; ref #2553 --- app/Services/Servers/BuildModificationService.php | 2 +- .../Services/Servers/BuildModificationServiceTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Services/Servers/BuildModificationService.php b/app/Services/Servers/BuildModificationService.php index c42264f8d..43c863831 100644 --- a/app/Services/Servers/BuildModificationService.php +++ b/app/Services/Servers/BuildModificationService.php @@ -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'])) { diff --git a/tests/Integration/Services/Servers/BuildModificationServiceTest.php b/tests/Integration/Services/Servers/BuildModificationServiceTest.php index ab3d6160f..1a4e81e2c 100644 --- a/tests/Integration/Services/Servers/BuildModificationServiceTest.php +++ b/tests/Integration/Services/Servers/BuildModificationServiceTest.php @@ -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]);