diff --git a/app/Actions/ViewService.php b/app/Actions/ViewService.php index f04384536..a4e620d4b 100644 --- a/app/Actions/ViewService.php +++ b/app/Actions/ViewService.php @@ -96,6 +96,7 @@ class ViewService /** @var Entity $instance */ foreach ($this->entityProvider->all() as $name => $instance) { $items = $instance::visible()->withLastView() + ->having('last_viewed_at', '>', 0) ->orderBy('last_viewed_at', 'desc') ->skip($count * ($page - 1)) ->take($count) diff --git a/tests/HomepageTest.php b/tests/HomepageTest.php index 943a3160a..a8e33465d 100644 --- a/tests/HomepageTest.php +++ b/tests/HomepageTest.php @@ -1,6 +1,9 @@ assertElementContains('.content-wrap', $shelf->name); $homeVisit->assertElementContains('.content-wrap', $book->name); } + + public function test_new_users_dont_have_any_recently_viewed() + { + $user = factory(User::class)->create(); + $viewRole = Role::getRole('Viewer'); + $user->attachRole($viewRole); + + $homeVisit = $this->actingAs($user)->get('/'); + $homeVisit->assertElementContains('#recently-viewed', 'You have not viewed any pages'); + } }