+ public function test_book_convert_to_shelf_requires_permissions()
+ {
+ $book = $this->entities->book();
+ $user = $this->users->viewer();
+
+ $permissions = ['book-delete-all', 'bookshelf-create-all', 'book-update-all', 'book-create-all'];
+ $this->permissions->grantUserRolePermissions($user, $permissions);
+
+ foreach ($permissions as $permission) {
+ $this->permissions->removeUserRolePermissions($user, [$permission]);
+ $resp = $this->actingAs($user)->post($book->getUrl('/convert-to-shelf'));
+ $this->assertPermissionError($resp);
+ $this->permissions->grantUserRolePermissions($user, [$permission]);
+ }
+
+ $resp = $this->actingAs($user)->post($book->getUrl('/convert-to-shelf'));
+ $this->assertNotPermissionError($resp);
+ $resp->assertRedirect();
+ }
+}