+ public function test_chapter_move_requires_delete_permissions()
+ {
+ $chapter = Chapter::first();
+ $currentBook = $chapter->book;
+ $newBook = Book::where('id', '!=', $currentBook->id)->first();
+ $editor = $this->getEditor();
+
+ $this->setEntityRestrictions($newBook, ['view', 'update', 'create', 'delete'], $editor->roles);
+ $this->setEntityRestrictions($chapter, ['view', 'update', 'create'], $editor->roles);
+
+ $moveChapterResp = $this->actingAs($editor)->put($chapter->getUrl('/move'), [
+ 'entity_selection' => 'book:' . $newBook->id
+ ]);
+ $this->assertPermissionError($moveChapterResp);
+ $pageView = $this->get($chapter->getUrl());
+ $pageView->assertDontSee($chapter->getUrl('/move'));
+
+ $this->setEntityRestrictions($chapter, ['view', 'update', 'create', 'delete'], $editor->roles);
+ $moveChapterResp = $this->put($chapter->getUrl('/move'), [
+ 'entity_selection' => 'book:' . $newBook->id
+ ]);
+
+ $chapter = Chapter::find($chapter->id);
+ $moveChapterResp->assertRedirect($chapter->getUrl());
+ $this->assertTrue($chapter->book->id == $newBook->id, 'Page book is now the new book');
+ }
+