mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Updated shelf menu item to show on custom permission
- Extended new 'userCanOnAny' helper to take a entity class for filtering. Closes #1201
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Auth\User;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
|
||||
@ -27,6 +29,22 @@ class BookShelfTest extends TestCase
|
||||
$resp->assertElementContains('header', 'Shelves');
|
||||
}
|
||||
|
||||
public function test_shelves_shows_in_header_if_have_any_shelve_view_permission()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$this->giveUserPermissions($user, ['image-create-all']);
|
||||
$shelf = Bookshelf::first();
|
||||
$userRole = $user->roles()->first();
|
||||
|
||||
$resp = $this->actingAs($user)->get('/');
|
||||
$resp->assertElementNotContains('header', 'Shelves');
|
||||
|
||||
$this->setEntityRestrictions($shelf, ['view'], [$userRole]);
|
||||
|
||||
$resp = $this->get('/');
|
||||
$resp->assertElementContains('header', 'Shelves');
|
||||
}
|
||||
|
||||
public function test_shelves_page_contains_create_link()
|
||||
{
|
||||
$resp = $this->asEditor()->get('/shelves');
|
||||
|
Reference in New Issue
Block a user