fix: menu location assignment is destructive, neutral download hint in media preview
This commit is contained in:
@@ -87,7 +87,7 @@ final class MediaPreviewAbility implements Ability
|
|||||||
if (! wp_attachment_is_image($id)) {
|
if (! wp_attachment_is_image($id)) {
|
||||||
return Errors::unsupported(
|
return Errors::unsupported(
|
||||||
'Das Medium ist kein Bild.',
|
'Das Medium ist kein Bild.',
|
||||||
'Metadaten über lit/media-get abrufen; Dateien über lit-media-download.'
|
'Metadaten über lit/media-get abrufen; Dateien über lit/media-download (direkt: lit-media-download).'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ final class MenuAssignLocationAbility implements Ability
|
|||||||
|
|
||||||
public function annotations(): array
|
public function annotations(): array
|
||||||
{
|
{
|
||||||
return ['readonly' => false, 'destructive' => false, 'idempotent' => true];
|
return ['readonly' => false, 'destructive' => true, 'idempotent' => true];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDirect(): bool
|
public function isDirect(): bool
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ final class MediaPreviewAbilityTest extends TestCase
|
|||||||
$result = (new MediaPreviewAbility())->execute(['id' => 33]);
|
$result = (new MediaPreviewAbility())->execute(['id' => 33]);
|
||||||
|
|
||||||
self::assertSame('lit_unsupported', $result->get_error_code());
|
self::assertSame('lit_unsupported', $result->get_error_code());
|
||||||
|
self::assertStringContainsString(
|
||||||
|
'lit/media-download (direkt: lit-media-download)',
|
||||||
|
(string) $result->get_error_data()['hint']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilesOutsideTheUploadsDirectoryAreRefused(): void
|
public function testFilesOutsideTheUploadsDirectoryAreRefused(): void
|
||||||
|
|||||||
@@ -122,4 +122,11 @@ final class MenuAssignLocationAbilityTest extends TestCase
|
|||||||
|
|
||||||
self::assertSame('lit_forbidden', $ability->permission($input)->get_error_code());
|
self::assertSame('lit_forbidden', $ability->permission($input)->get_error_code());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIsDestructiveBecauseItReplacesTheMenuOfTheLocation(): void
|
||||||
|
{
|
||||||
|
$ability = new MenuAssignLocationAbility(Mockery::mock(ChangeLog::class));
|
||||||
|
|
||||||
|
self::assertSame(['readonly' => false, 'destructive' => true, 'idempotent' => true], $ability->annotations());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user