mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 20:22:18 +00:00
Adds test cases and fixes an issue with the permission checking.
Signed-off-by: Abijeet <abijeetpatro@gmail.com>
This commit is contained in:
parent
0d4db603a4
commit
d5a2529775
@ -251,7 +251,9 @@ class UserController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function switchBookView($id, Request $request) {
|
public function switchBookView($id, Request $request) {
|
||||||
$this->checkPermission('users-manage');
|
$this->checkPermissionOr('users-manage', function () use ($id) {
|
||||||
|
return $this->currentUser->id == $id;
|
||||||
|
});
|
||||||
$viewType = $request->get('book_view_type');
|
$viewType = $request->get('book_view_type');
|
||||||
|
|
||||||
if (!in_array($viewType, ['grid', 'list'])) {
|
if (!in_array($viewType, ['grid', 'list'])) {
|
||||||
|
@ -82,6 +82,27 @@ class EntityTest extends BrowserKitTest
|
|||||||
->see($firstChapter->name);
|
->see($firstChapter->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_toggle_book_view()
|
||||||
|
{
|
||||||
|
$editor = $this->getEditor();
|
||||||
|
setting()->putUser($editor, 'books_view_type', 'grid');
|
||||||
|
|
||||||
|
$this->actingAs($editor)
|
||||||
|
->visit('/books')
|
||||||
|
->pageHasElement('.featured-image-container')
|
||||||
|
->submitForm('Toggle Book View')
|
||||||
|
// Check redirection.
|
||||||
|
->seePageIs('/books')
|
||||||
|
->pageNotHasElement('.featured-image-container');
|
||||||
|
|
||||||
|
$this->actingAs($editor)
|
||||||
|
->visit('/books')
|
||||||
|
->submitForm('Toggle Book View')
|
||||||
|
->seePageIs('/books')
|
||||||
|
->pageHasElement('.featured-image-container');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function pageCreation($chapter)
|
public function pageCreation($chapter)
|
||||||
{
|
{
|
||||||
$page = factory(Page::class)->make([
|
$page = factory(Page::class)->make([
|
||||||
|
@ -103,7 +103,7 @@ class UserProfileTest extends BrowserKitTest
|
|||||||
$this->actingAs($editor)
|
$this->actingAs($editor)
|
||||||
->visit('/books')
|
->visit('/books')
|
||||||
->pageNotHasElement('.featured-image-container')
|
->pageNotHasElement('.featured-image-container')
|
||||||
->pageHasElement('.entity-list-item');
|
->pageHasElement('.content .entity-list-item');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_books_view_is_grid()
|
public function test_books_view_is_grid()
|
||||||
|
Loading…
Reference in New Issue
Block a user