From: Dan Brown Date: Sat, 12 Nov 2016 13:21:16 +0000 (+0000) Subject: Fixed tag searches and added tag search regression test X-Git-Tag: v0.13.0~1^2~5 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/600055bc734ca649fae917b1ba1a9606f1ca0b00 Fixed tag searches and added tag search regression test Fixes #222 --- diff --git a/app/Entity.php b/app/Entity.php index 8a15b5aa4..186059f00 100644 --- a/app/Entity.php +++ b/app/Entity.php @@ -175,7 +175,8 @@ class Entity extends Ownable } } - $isFuzzy = count($exactTerms) === 0 || count($fuzzyTerms) > 0; + $isFuzzy = count($exactTerms) === 0 && count($fuzzyTerms) > 0; + // Perform fulltext search if relevant terms exist. if ($isFuzzy) { diff --git a/resources/assets/sass/_pages.scss b/resources/assets/sass/_pages.scss index c7d3e0377..880a9fdcc 100755 --- a/resources/assets/sass/_pages.scss +++ b/resources/assets/sass/_pages.scss @@ -238,6 +238,9 @@ flex-direction: column; overflow-y: scroll; } + table td, table th { + overflow: visible; + } } [toolbox-tab-content] { diff --git a/tests/Entity/EntitySearchTest.php b/tests/Entity/EntitySearchTest.php index cfdabdb0a..60b5ceebd 100644 --- a/tests/Entity/EntitySearchTest.php +++ b/tests/Entity/EntitySearchTest.php @@ -97,6 +97,39 @@ class EntitySearchTest extends TestCase ->seeStatusCode(200); } + public function test_tag_search() + { + $newTags = [ + new \BookStack\Tag([ + 'name' => 'animal', + 'value' => 'cat' + ]), + new \BookStack\Tag([ + 'name' => 'color', + 'value' => 'red' + ]) + ]; + + $pageA = \BookStack\Page::first(); + $pageA->tags()->saveMany($newTags); + + $pageB = \BookStack\Page::all()->last(); + $pageB->tags()->create(['name' => 'animal', 'value' => 'dog']); + + $this->asAdmin()->visit('/search/all?term=%5Banimal%5D') + ->seeLink($pageA->name) + ->seeLink($pageB->name); + + $this->visit('/search/all?term=%5Bcolor%5D') + ->seeLink($pageA->name) + ->dontSeeLink($pageB->name); + + $this->visit('/search/all?term=%5Banimal%3Dcat%5D') + ->seeLink($pageA->name) + ->dontSeeLink($pageB->name); + + } + public function test_ajax_entity_search() { $page = \BookStack\Page::all()->last();