diff --git a/app/controllers/SearchController.php b/app/controllers/SearchController.php index e1588d8e3b..978200c8c4 100644 --- a/app/controllers/SearchController.php +++ b/app/controllers/SearchController.php @@ -17,7 +17,7 @@ class SearchController extends BaseController $subTitle = null; $rawQuery = null; $result = []; - if (!is_null(Input::get('q'))) { + if (!is_null(Input::get('q')) && strlen(Input::get('q')) > 0) { $rawQuery = trim(Input::get('q')); $words = explode(' ', $rawQuery); $subTitle = 'Results for "' . e($rawQuery) . '"'; diff --git a/tests/functional/SearchControllerCest.php b/tests/functional/SearchControllerCest.php new file mode 100644 index 0000000000..973b2c54ab --- /dev/null +++ b/tests/functional/SearchControllerCest.php @@ -0,0 +1,39 @@ +amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']); + } + + public function index(FunctionalTester $I) + { + $I->wantTo('search for "salary"'); + $I->amOnPage('/search?q=salary'); + $I->see('Transactions'); + $I->see('Results for "salary"'); + + } + + public function indexNoQuery(FunctionalTester $I) + { + $I->wantTo('Search for empty string'); + $I->amOnPage('/search?q='); + $I->see('Search for ""'); + + } +} \ No newline at end of file