Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Actions/RenameAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ protected function fieldItems()
{
$asset = $this->items->first();

// The selected asset may no longer exist (e.g. it was renamed by a
// previous request), in which case there's nothing left to rename.
abort_unless($asset, 404);

return [
'filename' => [
'type' => 'text',
Expand Down
9 changes: 9 additions & 0 deletions tests/Actions/RenameAssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ public function it_renames()
$this->assertAssetExistsAndHasData('bravo.jpg', ['alt' => 'The alfa alt text']);
}

#[Test]
public function it_404s_when_the_selected_asset_does_not_exist()
{
$this
->actingAs(tap(User::make()->makeSuper())->save())
->rename('does-not-exist.jpg', 'bravo')
->assertNotFound();
}

#[Test]
public function it_fails_validation_if_provided_with_the_current_filename()
{
Expand Down
Loading