]> BookStack Code Mirror - bookstack/commitdiff
Fixed tag searches and added tag search regression test
authorDan Brown <redacted>
Sat, 12 Nov 2016 13:21:16 +0000 (13:21 +0000)
committerDan Brown <redacted>
Sat, 12 Nov 2016 13:21:16 +0000 (13:21 +0000)
Fixes #222

app/Entity.php
resources/assets/sass/_pages.scss
tests/Entity/EntitySearchTest.php

index 8a15b5aa4d85a94c75d40e447248de1312eafb14..186059f00e13848d88d5db6dd82b932366bbb7f3 100644 (file)
@@ -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) {
index c7d3e037731385229277f4871ace9432c43336bf..880a9fdcc1e4816e6bd5428d3a70fafaff514b8d 100755 (executable)
     flex-direction: column;
     overflow-y: scroll;
   }
+  table td, table th {
+    overflow: visible;
+  }
 }
 
 [toolbox-tab-content] {
index cfdabdb0ac9efbe500aa2a20017538899e4d0bb7..60b5ceebd4a8fe783d3eda3f7e9d7cd009b83fa5 100644 (file)
@@ -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();