mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Fixed misalignment of page and chapter parent book
Could occur when a chapter was moved with deleted pages. Fixes #2632
This commit is contained in:
@ -196,6 +196,24 @@ class SortTest extends TestCase
|
||||
$this->assertTrue($chapter->book->id == $newBook->id, 'Page book is now the new book');
|
||||
}
|
||||
|
||||
public function test_chapter_move_changes_book_for_deleted_pages_within()
|
||||
{
|
||||
/** @var Chapter $chapter */
|
||||
$chapter = Chapter::query()->whereHas('pages')->first();
|
||||
$currentBook = $chapter->book;
|
||||
$pageToCheck = $chapter->pages->first();
|
||||
$newBook = Book::query()->where('id', '!=', $currentBook->id)->first();
|
||||
|
||||
$pageToCheck->delete();
|
||||
|
||||
$this->asEditor()->put($chapter->getUrl('/move'), [
|
||||
'entity_selection' => 'book:' . $newBook->id
|
||||
]);
|
||||
|
||||
$pageToCheck->refresh();
|
||||
$this->assertEquals($newBook->id, $pageToCheck->book_id);
|
||||
}
|
||||
|
||||
public function test_book_sort()
|
||||
{
|
||||
$oldBook = Book::query()->first();
|
||||
|
Reference in New Issue
Block a user