Skip to content

Commit 2ff90e2

Browse files
committed
Merge branch 'master' into release
2 parents 04ecc12 + 9666c8c commit 2ff90e2

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

app/Entities/Repos/BookshelfRepo.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ public function __construct(BaseRepo $baseRepo)
2828
*/
2929
public function getAllPaginated(int $count = 20, string $sort = 'name', string $order = 'asc'): LengthAwarePaginator
3030
{
31-
return Bookshelf::visible()->with('visibleBooks')
32-
->orderBy($sort, $order)->paginate($count);
31+
return Bookshelf::visible()
32+
->with('visibleBooks')
33+
->orderBy($sort, $order)
34+
->paginate($count);
3335
}
3436

3537
/**

app/Http/Controllers/HomeController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ public function index()
6969
}
7070

7171
if ($homepageOption === 'bookshelves') {
72-
$shelfRepo = app(BookshelfRepo::class);
7372
$shelves = app(BookshelfRepo::class)->getAllPaginated(18, $commonData['sort'], $commonData['order']);
74-
foreach ($shelves as $shelf) {
75-
$shelf->books = $shelf->visibleBooks;
76-
}
7773
$data = array_merge($commonData, ['shelves' => $shelves]);
7874
return view('common.home-shelves', $data);
7975
}

resources/views/shelves/list-item.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</div>
1111
</a>
1212
<div class="entity-shelf-books grid third gap-y-xs entity-list-item-children">
13-
@foreach($shelf->books as $book)
13+
@foreach($shelf->visibleBooks as $book)
1414
<div>
1515
<a href="{{ $book->getUrl('?shelf=' . $shelf->id) }}" class="entity-chip text-book">
1616
@icon('book')

tests/Entity/BookShelfTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@ public function test_shelves_page_contains_create_link()
5656
$resp->assertElementContains('a', 'New Shelf');
5757
}
5858

59+
public function test_book_not_visible_in_shelf_list_view_if_user_cant_view_shelf()
60+
{
61+
config()->set([
62+
'app.views.bookshelves' => 'list',
63+
]);
64+
$shelf = Bookshelf::query()->first();
65+
$book = $shelf->books()->first();
66+
67+
$resp = $this->asEditor()->get('/shelves');
68+
$resp->assertSee($book->name);
69+
$resp->assertSee($book->getUrl());
70+
71+
$this->setEntityRestrictions($book, []);
72+
73+
$resp = $this->asEditor()->get('/shelves');
74+
$resp->assertDontSee($book->name);
75+
$resp->assertDontSee($book->getUrl());
76+
}
77+
5978
public function test_shelves_create()
6079
{
6180
$booksToInclude = Book::take(2)->get();

0 commit comments

Comments
 (0)