X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/1903422113a3962faf29d60c6ddf240164af7d4a..refs/pull/494/head:/tests/Permissions/RestrictionsTest.php diff --git a/tests/Permissions/RestrictionsTest.php b/tests/Permissions/RestrictionsTest.php index 75d83cbfc..faceab92c 100644 --- a/tests/Permissions/RestrictionsTest.php +++ b/tests/Permissions/RestrictionsTest.php @@ -1,6 +1,6 @@ -user = $this->getNewUser(); + $this->user = $this->getEditor(); $this->viewer = $this->getViewer(); $this->restrictionService = $this->app[\BookStack\Services\PermissionService::class]; } @@ -65,9 +65,9 @@ class RestrictionsTest extends TestCase $this->forceVisit($bookUrl) ->see('Book not found'); $this->forceVisit($bookPage->getUrl()) - ->see('Book not found'); + ->see('Page not found'); $this->forceVisit($bookChapter->getUrl()) - ->see('Book not found'); + ->see('Chapter not found'); $this->setEntityRestrictions($book, ['view']); @@ -226,6 +226,7 @@ class RestrictionsTest extends TestCase ->type('test content', 'html') ->press('Save Page') ->seePageIs($chapter->book->getUrl() . '/page/test-page'); + $this->visit($chapterUrl)->seeInElement('.action-buttons', 'New Page'); } @@ -522,4 +523,21 @@ class RestrictionsTest extends TestCase ->see('Delete Chapter'); } + public function test_page_visible_if_has_permissions_when_book_not_visible() + { + $book = \BookStack\Book::first(); + $bookChapter = $book->chapters->first(); + $bookPage = $bookChapter->pages->first(); + + $this->setEntityRestrictions($book, []); + $this->setEntityRestrictions($bookPage, ['view']); + + $this->actingAs($this->viewer); + $this->get($bookPage->getUrl()); + $this->assertResponseOk(); + $this->see($bookPage->name); + $this->dontSee(substr($book->name, 0, 15)); + $this->dontSee(substr($bookChapter->name, 0, 15)); + } + }