diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-11 23:43:02 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-11 23:43:02 +0200 |
| commit | 92c394b43a0603743b914c6298aab986805ca990 (patch) | |
| tree | 39308770fbae5558d98a7def3d25802ed8083d81 /test/models | |
| parent | 47beb3fe6ed6fdb75c2dd3a55362ad1aba3bbc3b (diff) | |
Add drafts/recent/mine/chapters admin node views
Four NodesController actions -- drafts, recent, mine, chapters --
each building its own base scope, sharing one private method
(index_matching) for search narrowing and pagination. Wizard rewrite
to link into these instead of rendering its own tables is a separate,
later step.
Node.editor_search backs the shared "q" narrowing: an ILIKE substring
match against title/abstract on whichever of head or draft is
present, splitting the term on whitespace and requiring every word to
match somewhere independently, not as one phrase, since real words can
end up separated by markup in the underlying HTML. Deliberately
separate from Node.search, the public content search, which stays
tsvector-based and head-only.
chapters generalizes into /admin/nodes/tags/:tags for an arbitrary
tag list (OR'd, not AND'd), sharing the controller action but
rendering its own template rather than branching inside one view.
Diffstat (limited to 'test/models')
| -rw-r--r-- | test/models/node_test.rb | 26 |
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 | ||
| 514 | end | 540 | end |
