feat(attachment): implement deletion of cropped attachments alongside original and update README

This commit is contained in:
2026-08-18 12:20:47 -03:00
parent 460ed528cf
commit 58cc35fd61
6 changed files with 37 additions and 4 deletions

View File

@@ -140,6 +140,25 @@ class AttachmentTest extends TestCase
}
}
public function test_it_deletes_the_crop_together_with_its_original(): void
{
Storage::fake('s3');
$original = app(AttachmentService::class)->storeCroppedImage(
UploadedFile::fake()->image('product.png'),
'attachments/acme',
10,
10,
);
$cropped = $original->croppedAttachment;
app(AttachmentService::class)->delete($original);
$this->assertDatabaseCount('attachments', 0);
Storage::disk('s3')->assertMissing($original->path);
Storage::disk('s3')->assertMissing($cropped->path);
}
public function test_it_deletes_from_s3_before_removing_the_database_record(): void
{
Storage::fake('s3');