Reset is_processing state of a schedule when toggling active/inactive; closes #2425
This commit is contained in:
parent
57457f0e9c
commit
2d01c7b988
2 changed files with 60 additions and 11 deletions
|
@ -9,6 +9,20 @@ use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
|
|||
|
||||
class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
||||
{
|
||||
/**
|
||||
* The data to use when updating a schedule.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $updateData = [
|
||||
'name' => 'Updated Schedule Name',
|
||||
'minute' => '5',
|
||||
'hour' => '*',
|
||||
'day_of_week' => '*',
|
||||
'day_of_month' => '*',
|
||||
'is_active' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* Test that a schedule can be updated.
|
||||
*
|
||||
|
@ -24,14 +38,7 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
$expected = Utilities::getScheduleNextRunDate('5', '*', '*', '*');
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}", [
|
||||
'name' => 'Updated Schedule Name',
|
||||
'minute' => '5',
|
||||
'hour' => '*',
|
||||
'day_of_week' => '*',
|
||||
'day_of_month' => '*',
|
||||
'is_active' => false,
|
||||
]);
|
||||
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}", $this->updateData);
|
||||
|
||||
$schedule = $schedule->refresh();
|
||||
|
||||
|
@ -74,6 +81,36 @@ class UpdateServerScheduleTest extends ClientApiIntegrationTestCase
|
|||
->assertForbidden();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the "is_processing" field gets reset to false when the schedule is enabled
|
||||
* or disabled so that an invalid state can be more easily fixed.
|
||||
*
|
||||
* @see https://github.com/pterodactyl/panel/issues/2425
|
||||
*/
|
||||
public function testScheduleIsProcessingIsSetToFalseWhenActiveStateChanges()
|
||||
{
|
||||
[$user, $server] = $this->generateTestAccount();
|
||||
|
||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
||||
$schedule = factory(Schedule::class)->create([
|
||||
'server_id' => $server->id,
|
||||
'is_active' => true,
|
||||
'is_processing' => true,
|
||||
]);
|
||||
|
||||
$this->assertTrue($schedule->is_active);
|
||||
$this->assertTrue($schedule->is_processing);
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->postJson("/api/client/servers/{$server->uuid}/schedules/{$schedule->id}", $this->updateData);
|
||||
|
||||
$schedule = $schedule->refresh();
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertFalse($schedule->is_active);
|
||||
$this->assertFalse($schedule->is_processing);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue