Show bookshelves that a book belongs to on a book view

Closes #1598
This commit is contained in:
Christopher Wilkinson
2019-09-27 00:45:10 +01:00
parent 7cd956b24b
commit 4ad4dfa55a
5 changed files with 52 additions and 3 deletions

View File

@ -240,4 +240,32 @@ class BookShelfTest extends TestCase
$pageVisit->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
}
public function test_bookshelves_show_on_book()
{
// Create shelf
$shelfInfo = [
'name' => 'My test shelf' . Str::random(4),
'description' => 'Test shelf description ' . Str::random(10)
];
$this->asEditor()->post('/shelves', $shelfInfo);
$shelf = Bookshelf::where('name', '=', $shelfInfo['name'])->first();
// Create book and add to shelf
$this->asEditor()->post($shelf->getUrl('/create-book'), [
'name' => 'Test book name',
'description' => 'Book in shelf description'
]);
$newBook = Book::query()->orderBy('id', 'desc')->first();
$resp = $this->asEditor()->get($newBook->getUrl());
$resp->assertSee($shelfInfo['name']);
// Remove shelf
$this->delete($shelf->getUrl());
$resp = $this->asEditor()->get($newBook->getUrl());
$resp->assertDontSee($shelfInfo['name']);
}
}