1
0
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:
Dan Brown
2021-03-13 15:18:37 +00:00
parent 26730e56ea
commit 339d4ec355
3 changed files with 26 additions and 14 deletions

View File

@ -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();