1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Added TestCase for attachments API methods

This commit is contained in:
Dan Brown
2021-10-20 00:58:56 +01:00
parent 32f6ea946f
commit 2409d1850f
6 changed files with 359 additions and 10 deletions

View File

@ -25,8 +25,8 @@ class AttachmentApiController extends ApiController
'update' => [
'name' => 'min:1|max:255|string',
'uploaded_to' => 'integer|exists:pages,id',
'file' => 'link|file',
'link' => 'file|min:1|max:255|safe_url'
'file' => 'file',
'link' => 'min:1|max:255|safe_url'
],
];
@ -87,7 +87,9 @@ class AttachmentApiController extends ApiController
public function read(string $id)
{
/** @var Attachment $attachment */
$attachment = Attachment::visible()->findOrFail($id);
$attachment = Attachment::visible()
->with(['createdBy', 'updatedBy'])
->findOrFail($id);
$attachment->setAttribute('links', [
'html' => $attachment->htmlLink(),
@ -129,7 +131,7 @@ class AttachmentApiController extends ApiController
if ($request->hasFile('file')) {
$uploadedFile = $request->file('file');
$attachment = $this->attachmentService->saveUpdatedUpload($uploadedFile, $page->id);
$attachment = $this->attachmentService->saveUpdatedUpload($uploadedFile, $attachment);
}
$this->attachmentService->updateFile($attachment, $requestData);