mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-24 20:02:35 +01:00
Merge branch 'philjak-feature_move_page_into_chapter'
This commit is contained in:
commit
90f9240be4
@ -306,9 +306,11 @@ class PageRepo
|
||||
throw new PermissionsException('User does not have permission to create a page within the new parent');
|
||||
}
|
||||
|
||||
$page->chapter_id = ($parent instanceof Chapter) ? $parent->id : null;
|
||||
$page->changeBook($parent instanceof Book ? $parent->id : $parent->book->id);
|
||||
$page->rebuildPermissions();
|
||||
return $parent;
|
||||
|
||||
return ($parent instanceof Book ? $parent : $parent->book);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,10 +66,28 @@ class SortTest extends TestCase
|
||||
$this->assertTrue($page->book->id == $newBook->id, 'Page parent is now the new chapter');
|
||||
|
||||
$newChapterResp = $this->get($newChapter->getUrl());
|
||||
$newChapterResp->assertSee('moved page');
|
||||
$newChapterResp->assertSee($page->name);
|
||||
}
|
||||
|
||||
public function test_page_move_from_chapter_to_book()
|
||||
{
|
||||
$oldChapter = Chapter::first();
|
||||
$page = $oldChapter->pages()->first();
|
||||
$newBook = Book::where('id', '!=', $oldChapter->book_id)->first();
|
||||
|
||||
$movePageResp = $this->actingAs($this->getEditor())->put($page->getUrl('/move'), [
|
||||
'entity_selection' => 'book:' . $newBook->id
|
||||
]);
|
||||
$page = Page::find($page->id);
|
||||
|
||||
$movePageResp->assertRedirect($page->getUrl());
|
||||
$this->assertTrue($page->book->id == $newBook->id, 'Page parent is now the new book');
|
||||
$this->assertTrue($page->chapter === null, 'Page has no parent chapter');
|
||||
|
||||
$newBookResp = $this->get($newBook->getUrl());
|
||||
$newBookResp->assertSee($page->name);
|
||||
}
|
||||
|
||||
public function test_page_move_requires_create_permissions_on_parent()
|
||||
{
|
||||
$page = Page::first();
|
||||
|
Loading…
Reference in New Issue
Block a user