Skip to content

Commit cb40b28

Browse files
committed
Fix single failing test
1 parent a75a347 commit cb40b28

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

app/Http/Controllers/Api/Remote/Servers/ServerInstallController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Http\Request;
66
use Illuminate\Http\Response;
7+
use Pterodactyl\Models\Server;
78
use Illuminate\Http\JsonResponse;
89
use Pterodactyl\Http\Controllers\Controller;
910
use Pterodactyl\Repositories\Eloquent\ServerRepository;
@@ -61,10 +62,13 @@ public function store(InstallationDataRequest $request, string $uuid)
6162
{
6263
$server = $this->repository->getByUuid($uuid);
6364

64-
$this->repository->update($server->id, [
65-
'installed' => (string) $request->input('successful') === '1' ? 1 : 2,
66-
], true, true);
65+
$status = $request->input('successful') === '1' ? null : Server::STATUS_INSTALL_FAILED;
66+
if ($server->status === Server::STATUS_SUSPENDED) {
67+
$status = Server::STATUS_SUSPENDED
68+
}
6769

68-
return JsonResponse::create([], Response::HTTP_NO_CONTENT);
70+
$this->repository->update($server->id, ['status' => $status], true, true);
71+
72+
return new JsonResponse([], Response::HTTP_NO_CONTENT);
6973
}
7074
}

app/Models/Server.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ class Server extends Model
129129
'startup' => 'required|string',
130130
'skip_scripts' => 'sometimes|boolean',
131131
'image' => 'required|string|max:191',
132-
'installed' => 'in:0,1,2',
133132
'database_limit' => 'present|nullable|integer|min:0',
134133
'allocation_limit' => 'sometimes|nullable|integer|min:0',
135134
'backup_limit' => 'present|nullable|integer|min:0',

tests/Unit/Http/Middleware/Server/AccessingValidServerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testExceptionIsThrownIfServerIsNotInstalled()
6767
$this->expectException(ConflictHttpException::class);
6868
$this->expectExceptionMessage('Server is still completing the installation process.');
6969

70-
$model = factory(Server::class)->make(['installed' => 0]);
70+
$model = factory(Server::class)->make(['status' => Server::STATUS_INSTALLING]);
7171

7272
$this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456');
7373
$this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true);

0 commit comments

Comments
 (0)