+ public function test_convert_chapter_to_book_requires_permissions()
+ {
+ /** @var Chapter $chapter */
+ $chapter = Chapter::query()->first();
+ $user = $this->getViewer();
+
+ $permissions = ['chapter-delete-all', 'book-create-all', 'chapter-update-all'];
+ $this->giveUserPermissions($user, $permissions);
+
+ foreach ($permissions as $permission) {
+ $this->removePermissionFromUser($user, $permission);
+ $resp = $this->actingAs($user)->post($chapter->getUrl('/convert-to-book'));
+ $this->assertPermissionError($resp);
+ $this->giveUserPermissions($user, [$permission]);
+ }
+
+ $resp = $this->actingAs($user)->post($chapter->getUrl('/convert-to-book'));
+ $this->assertNotPermissionError($resp);
+ $resp->assertRedirect();
+ }
+