+
+ public function test_copy_adds_book_to_shelves_if_edit_permissions_allows()
+ {
+ /** @var Bookshelf $shelfA */
+ /** @var Bookshelf $shelfB */
+ [$shelfA, $shelfB] = Bookshelf::query()->take(2)->get();
+ $book = $this->entities->book();
+
+ $shelfA->appendBook($book);
+ $shelfB->appendBook($book);
+
+ $viewer = $this->users->viewer();
+ $this->permissions->grantUserRolePermissions($viewer, ['book-update-all', 'book-create-all', 'bookshelf-update-all']);
+ $this->permissions->setEntityPermissions($shelfB);
+
+
+ $this->asEditor()->post($book->getUrl('/copy'), ['name' => 'My copy book']);
+ /** @var Book $copy */
+ $copy = Book::query()->where('name', '=', 'My copy book')->first();
+
+ $this->assertTrue($copy->shelves()->where('id', '=', $shelfA->id)->exists());
+ $this->assertFalse($copy->shelves()->where('id', '=', $shelfB->id)->exists());
+ }