diff --git a/resources/views/books/parts/form.blade.php b/resources/views/books/parts/form.blade.php index 973bae98701..e22be619d66 100644 --- a/resources/views/books/parts/form.blade.php +++ b/resources/views/books/parts/form.blade.php @@ -49,7 +49,7 @@ @include('form.page-picker', [ 'name' => 'default_template_id', 'placeholder' => trans('entities.books_default_template_select'), - 'value' => $book?->default_template_id ?? null, + 'value' => $book->default_template_id ?? null, ]) diff --git a/tests/Entity/BookDefaultTemplateTest.php b/tests/Entity/BookDefaultTemplateTest.php index f23ba4a8e2d..d4cd5b2c3a9 100644 --- a/tests/Entity/BookDefaultTemplateTest.php +++ b/tests/Entity/BookDefaultTemplateTest.php @@ -159,6 +159,21 @@ public function test_creating_book_page_does_not_use_template_if_not_visible() $this->assertEquals('', $latestPage->markdown); } + public function test_template_page_delete_removes_book_template_usage() + { + $templatePage = $this->entities->templatePage(); + $book = $this->bookUsingDefaultTemplate($templatePage); + + $book->refresh(); + $this->assertEquals($templatePage->id, $book->default_template_id); + + $this->asEditor()->delete($templatePage->getUrl()); + $this->asAdmin()->post('/settings/recycle-bin/empty'); + + $book->refresh(); + $this->assertEquals(null, $book->default_template_id); + } + protected function bookUsingDefaultTemplate(Page $page): Book { $book = $this->entities->book();