summaryrefslogtreecommitdiff
path: root/test/models/node_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/models/node_test.rb')
-rw-r--r--test/models/node_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/models/node_test.rb b/test/models/node_test.rb
index 5626384..15e908b 100644
--- a/test/models/node_test.rb
+++ b/test/models/node_test.rb
@@ -511,4 +511,30 @@ class NodeTest < ActiveSupport::TestCase
511 a.reload 511 a.reload
512 assert_equal Node.root.id, a.parent_id 512 assert_equal Node.root.id, a.parent_id
513 end 513 end
514
515 test "editor_search matches a partial substring, not just a whole word" do
516 node = Node.root.children.create!(:slug => "editor_search_substring_test")
517 node.find_or_create_draft(@user1)
518 node.draft.update(:title => "Biometrics Conference")
519 node.publish_draft!
520
521 assert_includes Node.editor_search("bio"), node
522 assert_includes Node.editor_search("Conf"), node
523 end
524
525 test "editor_search returns an empty relation for a blank term, not every node" do
526 assert_equal 0, Node.editor_search("").count
527 assert_equal 0, Node.editor_search(nil).count
528 assert_equal 0, Node.editor_search(" ").count
529 end
530
531 test "editor_search requires every word to match, but each word can match a different field" do
532 node = Node.root.children.create!(:slug => "editor_search_multiword_test")
533 node.find_or_create_draft(@user1)
534 node.draft.update(:title => "Backspace e.V. Bamberg", :abstract => "Spiegelgraben 41, 96052 Bamberg")
535 node.publish_draft!
536
537 assert_includes Node.editor_search("Backspace Spiegelgraben"), node
538 assert_equal 0, Node.editor_search("Backspace Nonexistentstreet").count
539 end
514end 540end