mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Added test & update to prevent page creation w/ empty slug
Caused by changes to page repo in reference work, This adds back in the slug generate although at a more central place. Adds a test case to cover the problematic scenario.
This commit is contained in:
@ -204,4 +204,32 @@ class PageDraftTest extends TestCase
|
||||
$draft->refresh();
|
||||
$this->assertStringContainsString('href="https://example.com"', $draft->html);
|
||||
}
|
||||
|
||||
public function test_slug_generated_on_draft_publish_to_page_when_no_name_change()
|
||||
{
|
||||
/** @var Book $book */
|
||||
$book = Book::query()->first();
|
||||
$this->asEditor()->get($book->getUrl('/create-page'));
|
||||
/** @var Page $draft */
|
||||
$draft = Page::query()->where('draft', '=', true)->where('book_id', '=', $book->id)->firstOrFail();
|
||||
|
||||
$this->put('/ajax/page/' . $draft->id . '/save-draft', [
|
||||
'name' => 'My page',
|
||||
'markdown' => "Update test",
|
||||
])->assertOk();
|
||||
|
||||
$draft->refresh();
|
||||
$this->assertEmpty($draft->slug);
|
||||
|
||||
$this->post($draft->getUrl(), [
|
||||
'name' => 'My page',
|
||||
'markdown' => "# My markdown page"
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('pages', [
|
||||
'id' => $draft->id,
|
||||
'draft' => false,
|
||||
'slug' => 'my-page',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user