fix: allow deleting partial restore runs
Normalize RestoreRun status in isDeletable() so 'Partial'/'completed-with-errors' variants can be archived.
This commit is contained in:
parent
eef9618889
commit
0a6e1f7751
@ -41,6 +41,9 @@ public function scopeDeletable($query)
|
||||
|
||||
public function isDeletable(): bool
|
||||
{
|
||||
return in_array($this->status, ['completed', 'failed', 'aborted', 'completed_with_errors', 'partial'], true);
|
||||
$status = strtolower(trim((string) $this->status));
|
||||
$status = str_replace([' ', '-'], '_', $status);
|
||||
|
||||
return in_array($status, ['completed', 'failed', 'aborted', 'completed_with_errors', 'partial'], true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,3 +54,33 @@
|
||||
'partial',
|
||||
]);
|
||||
});
|
||||
|
||||
test('isDeletable accepts partial even if status casing/format differs', function () {
|
||||
$tenant = Tenant::factory()->create();
|
||||
|
||||
$backupSet = BackupSet::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'name' => 'Backup',
|
||||
'status' => 'completed',
|
||||
'item_count' => 0,
|
||||
]);
|
||||
|
||||
$partial = RestoreRun::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'backup_set_id' => $backupSet->id,
|
||||
'status' => 'Partial',
|
||||
'is_dry_run' => true,
|
||||
'requested_by' => 'tester@example.com',
|
||||
]);
|
||||
|
||||
$completedWithErrors = RestoreRun::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'backup_set_id' => $backupSet->id,
|
||||
'status' => 'completed-with-errors',
|
||||
'is_dry_run' => true,
|
||||
'requested_by' => 'tester@example.com',
|
||||
]);
|
||||
|
||||
expect($partial->isDeletable())->toBeTrue();
|
||||
expect($completedWithErrors->isDeletable())->toBeTrue();
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user