Dan Brown

Fixed tag searches and added tag search regression test

Fixes #222
...@@ -175,7 +175,8 @@ class Entity extends Ownable ...@@ -175,7 +175,8 @@ class Entity extends Ownable
175 } 175 }
176 } 176 }
177 177
178 - $isFuzzy = count($exactTerms) === 0 || count($fuzzyTerms) > 0; 178 + $isFuzzy = count($exactTerms) === 0 && count($fuzzyTerms) > 0;
179 +
179 180
180 // Perform fulltext search if relevant terms exist. 181 // Perform fulltext search if relevant terms exist.
181 if ($isFuzzy) { 182 if ($isFuzzy) {
......
...@@ -238,6 +238,9 @@ ...@@ -238,6 +238,9 @@
238 flex-direction: column; 238 flex-direction: column;
239 overflow-y: scroll; 239 overflow-y: scroll;
240 } 240 }
241 + table td, table th {
242 + overflow: visible;
243 + }
241 } 244 }
242 245
243 [toolbox-tab-content] { 246 [toolbox-tab-content] {
......
...@@ -97,6 +97,39 @@ class EntitySearchTest extends TestCase ...@@ -97,6 +97,39 @@ class EntitySearchTest extends TestCase
97 ->seeStatusCode(200); 97 ->seeStatusCode(200);
98 } 98 }
99 99
100 + public function test_tag_search()
101 + {
102 + $newTags = [
103 + new \BookStack\Tag([
104 + 'name' => 'animal',
105 + 'value' => 'cat'
106 + ]),
107 + new \BookStack\Tag([
108 + 'name' => 'color',
109 + 'value' => 'red'
110 + ])
111 + ];
112 +
113 + $pageA = \BookStack\Page::first();
114 + $pageA->tags()->saveMany($newTags);
115 +
116 + $pageB = \BookStack\Page::all()->last();
117 + $pageB->tags()->create(['name' => 'animal', 'value' => 'dog']);
118 +
119 + $this->asAdmin()->visit('/search/all?term=%5Banimal%5D')
120 + ->seeLink($pageA->name)
121 + ->seeLink($pageB->name);
122 +
123 + $this->visit('/search/all?term=%5Bcolor%5D')
124 + ->seeLink($pageA->name)
125 + ->dontSeeLink($pageB->name);
126 +
127 + $this->visit('/search/all?term=%5Banimal%3Dcat%5D')
128 + ->seeLink($pageA->name)
129 + ->dontSeeLink($pageB->name);
130 +
131 + }
132 +
100 public function test_ajax_entity_search() 133 public function test_ajax_entity_search()
101 { 134 {
102 $page = \BookStack\Page::all()->last(); 135 $page = \BookStack\Page::all()->last();
......