mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-23 12:20:21 +00:00
parent
c1f070a136
commit
68ef6a842f
2 changed files with 24 additions and 1 deletions
|
@ -212,7 +212,7 @@ class PageRepo
|
|||
if (!empty($input['markdown'] ?? '')) {
|
||||
$pageContent->setNewMarkdown($input['markdown']);
|
||||
} else {
|
||||
$pageContent->setNewHTML($input['html']);
|
||||
$pageContent->setNewHTML($input['html'] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue