Allowed creating pages in visible chapters in invisible books

Fixes permissions with test to cover in the event a page is created,
with permission, in a chapter but the user does not have permission to
see the parent book.

Fixes #912
This commit is contained in:
Dan Brown
2018-07-14 14:12:29 +01:00
parent b2cd363539
commit 2bcc159fd6
3 changed files with 52 additions and 11 deletions

View File

@ -592,4 +592,26 @@ class RestrictionsTest extends BrowserKitTest
->see('You do not have permission')
->seePageIs('/');
}
public function test_can_create_page_if_chapter_has_permissions_when_book_not_visible()
{
$book = Book::first();
$this->setEntityRestrictions($book, []);
$bookChapter = $book->chapters->first();
$this->setEntityRestrictions($bookChapter, ['view']);
$this->actingAs($this->user)->visit($bookChapter->getUrl())
->dontSee('New Page');
$this->setEntityRestrictions($bookChapter, ['view', 'create']);
$this->actingAs($this->user)->visit($bookChapter->getUrl())
->click('New Page')
->seeStatusCode(200)
->type('test page', 'name')
->type('test content', 'html')
->press('Save Page')
->seePageIs($book->getUrl('/page/test-page'))
->seeStatusCode(200);
}
}