0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-23 12:20:21 +00:00

Fixed issue thrown upon empty markdown content save

Closes 
This commit is contained in:
Dan Brown 2021-05-15 17:33:53 +01:00
parent c1f070a136
commit 68ef6a842f
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
2 changed files with 24 additions and 1 deletions
app/Entities/Repos
tests/Entity

View file

@ -212,7 +212,7 @@ class PageRepo
if (!empty($input['markdown'] ?? '')) {
$pageContent->setNewMarkdown($input['markdown']);
} else {
$pageContent->setNewHTML($input['html']);
$pageContent->setNewHTML($input['html'] ?? '');
}
}

View file

@ -161,4 +161,27 @@ class PageTest extends TestCase
'book_id' => $newBook->id,
]);
}
public function test_empty_markdown_still_saves_without_error()
{
$this->setSettings(['app-editor' => 'markdown']);
$book = Book::query()->first();
$this->asEditor()->get($book->getUrl('/create-page'));
$draft = Page::query()->where('book_id', '=', $book->id)
->where('draft', '=', true)->first();
$details = [
'name' => 'my page',
'markdown' => '',
];
$resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
$resp->assertRedirect();
$this->assertDatabaseHas('pages', [
'markdown' => $details['markdown'],
'id' => $draft->id,
'draft' => false
]);
}
}