feat/005-bulk-operations #5

Merged
ahmido merged 25 commits from feat/005-bulk-operations into dev 2025-12-25 13:32:37 +00:00
2 changed files with 34 additions and 1 deletions
Showing only changes of commit 0a6e1f7751 - Show all commits

View File

@ -41,6 +41,9 @@ public function scopeDeletable($query)
public function isDeletable(): bool 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);
} }
} }

View File

@ -54,3 +54,33 @@
'partial', '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();
});