1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-01-03 23:42:28 +03:00

Improved custom homepage check on item deletion

Custom homepage usage will now be checked before any actioning
of deletion rather than potentially causing an exception acting
during the deletion.

Previously a deletion could still be created, within the recycle bin,
for the parent which may lead to the page being deleted anyway.

For #3150
This commit is contained in:
Dan Brown
2022-01-10 17:04:01 +00:00
parent 722aa04577
commit 8d91f4369b
3 changed files with 58 additions and 7 deletions

View File

@@ -79,6 +79,24 @@ class HomepageTest extends TestCase
$pageDeleteReq->assertSessionMissing('error');
}
public function test_custom_homepage_cannot_be_deleted_from_parent_deletion()
{
/** @var Page $page */
$page = Page::query()->first();
$this->setSettings([
'app-homepage' => $page->id,
'app-homepage-type' => 'page',
]);
$this->asEditor()->delete($page->book->getUrl());
$this->assertSessionError('Cannot delete a page while it is set as a homepage');
$this->assertDatabaseMissing('deletions', ['deletable_id' => $page->book->id]);
$page->refresh();
$this->assertNull($page->deleted_at);
$this->assertNull($page->book->deleted_at);
}
public function test_custom_homepage_renders_includes()
{
$this->asEditor();