From 1983fc5f7afa20b5ddba0ad1fb63fb92f563deb6 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 19 Aug 2015 21:12:17 -0400 Subject: Show all tasks when using no search criteria --- ChangeLog | 1 + app/Model/TaskFilter.php | 2 +- tests/units/TaskFilterTest.php | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c3c29305..4391d515 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ New features: Improvements: +* Show all tasks when using no search criteria * Add column vertical scrolling * Set dynamically column height based on viewport size * Enable support for Github Enterprise when using Github Authentication diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php index 8da4a214..e8926b52 100644 --- a/app/Model/TaskFilter.php +++ b/app/Model/TaskFilter.php @@ -36,7 +36,7 @@ class TaskFilter extends Base $this->query = $this->taskFinder->getExtendedQuery(); if (empty($tree)) { - $this->query->addCondition('1 = 0'); + $this->filterByTitle($input); } foreach ($tree as $filter => $value) { diff --git a/tests/units/TaskFilterTest.php b/tests/units/TaskFilterTest.php index 5f606d7a..504aa5c2 100644 --- a/tests/units/TaskFilterTest.php +++ b/tests/units/TaskFilterTest.php @@ -80,6 +80,24 @@ class TaskFilterTest extends Base $this->assertEmpty($tf->search('search something')->findAll()); } + public function testSearchWithEmptyInput() + { + $dp = new DateParser($this->container); + $p = new Project($this->container); + $tc = new TaskCreation($this->container); + $tf = new TaskFilter($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is awesome', 'date_due' => $dp->getTimestampFromIsoFormat('-2 days')))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is amazing', 'date_due' => $dp->getTimestampFromIsoFormat('+1 day')))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'Bob at work', 'date_due' => $dp->getTimestampFromIsoFormat('-1 day')))); + $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'youpi', 'date_due' => $dp->getTimestampFromIsoFormat(time())))); + + $result = $tf->search('')->findAll(); + $this->assertNotEmpty($result); + $this->assertCount(4, $result); + } + public function testSearchById() { $p = new Project($this->container); -- cgit v1.2.3