Dan Brown

Fixed incorrect recents pages on homescreen

Fixed the bug causing the recently updated pages to be exaclty the same as the recently create pages.
Also added in tests to prevent regression.
...@@ -24,7 +24,6 @@ class HomeController extends Controller ...@@ -24,7 +24,6 @@ class HomeController extends Controller
24 24
25 /** 25 /**
26 * Display the homepage. 26 * Display the homepage.
27 - *
28 * @return Response 27 * @return Response
29 */ 28 */
30 public function index() 29 public function index()
......
...@@ -33,10 +33,14 @@ ...@@ -33,10 +33,14 @@
33 33
34 <div class="col-sm-4"> 34 <div class="col-sm-4">
35 <h3><a class="no-color" href="/pages/recently-created">Recently Created Pages</a></h3> 35 <h3><a class="no-color" href="/pages/recently-created">Recently Created Pages</a></h3>
36 + <div id="recently-created-pages">
36 @include('partials/entity-list', ['entities' => $recentlyCreatedPages, 'style' => 'compact']) 37 @include('partials/entity-list', ['entities' => $recentlyCreatedPages, 'style' => 'compact'])
38 + </div>
37 39
38 <h3><a class="no-color" href="/pages/recently-updated">Recently Updated Pages</a></h3> 40 <h3><a class="no-color" href="/pages/recently-updated">Recently Updated Pages</a></h3>
39 - @include('partials/entity-list', ['entities' => $recentlyCreatedPages, 'style' => 'compact']) 41 + <div id="recently-updated-pages">
42 + @include('partials/entity-list', ['entities' => $recentlyUpdatedPages, 'style' => 'compact'])
43 + </div>
40 </div> 44 </div>
41 45
42 <div class="col-sm-4" id="recent-activity"> 46 <div class="col-sm-4" id="recent-activity">
......
...@@ -225,4 +225,22 @@ class EntityTest extends TestCase ...@@ -225,4 +225,22 @@ class EntityTest extends TestCase
225 ->seePageIs($newPageUrl); 225 ->seePageIs($newPageUrl);
226 } 226 }
227 227
228 + public function test_recently_updated_pages_on_home()
229 + {
230 + $page = \BookStack\Page::orderBy('updated_at', 'asc')->first();
231 + $this->asAdmin()->visit('/')
232 + ->dontSeeInElement('#recently-updated-pages', $page->name);
233 + $this->visit($page->getUrl() . '/edit')
234 + ->press('Save Page')
235 + ->visit('/')
236 + ->seeInElement('#recently-updated-pages', $page->name);
237 + }
238 +
239 + public function test_recently_created_pages_on_home()
240 + {
241 + $entityChain = $this->createEntityChainBelongingToUser($this->getNewUser());
242 + $this->asAdmin()->visit('/')
243 + ->seeInElement('#recently-created-pages', $entityChain['page']->name);
244 + }
245 +
228 } 246 }
......