feat(project-bulk): distinguish supplier_snapshot_locked from has_deals in bulkDelete
This commit is contained in:
@@ -312,8 +312,15 @@ class ProjectService
|
||||
try {
|
||||
$this->delete($model);
|
||||
$deleted++;
|
||||
} catch (HttpResponseException) {
|
||||
$skipped[] = ['id' => $p->id, 'reason' => 'has_deals'];
|
||||
} catch (HttpResponseException $e) {
|
||||
// Spec: docs/superpowers/plans/2026-05-26-supplier-snapshot-guard.md (Task 12).
|
||||
// Разделяем причину: guard поставщика (нужно подождать) vs has-deals.
|
||||
$body = json_decode((string) $e->getResponse()->getContent(), true);
|
||||
$message = (string) ($body['errors']['project'][0] ?? '');
|
||||
$reason = str_contains($message, 'Мы уже начали сбор лидов')
|
||||
? 'supplier_snapshot_locked'
|
||||
: 'has_deals';
|
||||
$skipped[] = ['id' => $p->id, 'reason' => $reason];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,15 @@ class PausedAtWriteSideTest extends TestCase
|
||||
$this->assertStringContainsString('is_active', $body);
|
||||
}
|
||||
|
||||
public function test_bulk_delete_distinguishes_supplier_snapshot_lock_from_has_deals(): void
|
||||
{
|
||||
$body = $this->methodBody(ProjectService::class, 'bulkDelete');
|
||||
|
||||
$this->assertStringContainsString('supplier_snapshot_locked', $body,
|
||||
'bulkDelete должен помечать пропущенные проекты reason="supplier_snapshot_locked" при guard-блоке');
|
||||
$this->assertStringContainsString('has_deals', $body);
|
||||
}
|
||||
|
||||
private function methodBody(string $class, string $method): string
|
||||
{
|
||||
$rm = new ReflectionMethod($class, $method);
|
||||
|
||||
Reference in New Issue
Block a user