mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Updated pages API to not clear content if not provided
Can now update page details without supplying page content. Added test to cover. Closes #2856
This commit is contained in:
parent
822fea4303
commit
b005acdd6c
@ -218,8 +218,8 @@ class PageRepo
|
||||
$pageContent = new PageContent($page);
|
||||
if (!empty($input['markdown'] ?? '')) {
|
||||
$pageContent->setNewMarkdown($input['markdown']);
|
||||
} else {
|
||||
$pageContent->setNewHTML($input['html'] ?? '');
|
||||
} else if (isset($input['html'])) {
|
||||
$pageContent->setNewHTML($input['html']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,6 +219,27 @@ class PagesApiTest extends TestCase
|
||||
$resp->assertStatus(403);
|
||||
}
|
||||
|
||||
public function test_update_endpoint_does_not_wipe_content_if_no_html_or_md_provided()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
$page = Page::visible()->first();
|
||||
$originalContent = $page->html;
|
||||
$details = [
|
||||
'name' => 'My updated API page',
|
||||
'tags' => [
|
||||
[
|
||||
'name' => 'freshtag',
|
||||
'value' => 'freshtagval',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->putJson($this->baseEndpoint . "/{$page->id}", $details);
|
||||
$page->refresh();
|
||||
|
||||
$this->assertEquals($originalContent, $page->html);
|
||||
}
|
||||
|
||||
public function test_delete_endpoint()
|
||||
{
|
||||
$this->actingAsApiEditor();
|
||||
|
Loading…
Reference in New Issue
Block a user