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/controllers | |
| 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/controllers')
| -rw-r--r-- | test/controllers/nodes_controller_test.rb | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index b563d4d..05cb195 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb | |||
| @@ -471,4 +471,108 @@ class NodesControllerTest < ActionController::TestCase | |||
| 471 | assert_response :success | 471 | assert_response :success |
| 472 | assert_select "form.destructive", :count => 0 | 472 | assert_select "form.destructive", :count => 0 |
| 473 | end | 473 | end |
| 474 | |||
| 475 | test "drafts includes a never-published node with only a draft" do | ||
| 476 | node = Node.root.children.create!(:slug => "drafts_action_test") | ||
| 477 | login_as :quentin | ||
| 478 | get :drafts | ||
| 479 | assert_includes assigns(:nodes), node | ||
| 480 | end | ||
| 481 | |||
| 482 | test "chapters filters by kind, matching head or draft, and shows both by default" do | ||
| 483 | erfa_node = Node.root.children.create!(:slug => "chapters_erfa_test") | ||
| 484 | erfa_node.find_or_create_draft(@user1) | ||
| 485 | erfa_node.draft.tag_list = "erfa-detail" | ||
| 486 | erfa_node.draft.save! | ||
| 487 | erfa_node.publish_draft! | ||
| 488 | |||
| 489 | chaostreff_node = Node.root.children.create!(:slug => "chapters_chaostreff_test") | ||
| 490 | chaostreff_node.find_or_create_draft(@user1) | ||
| 491 | chaostreff_node.draft.tag_list = "chaostreff-detail" | ||
| 492 | chaostreff_node.draft.save! | ||
| 493 | chaostreff_node.publish_draft! | ||
| 494 | |||
| 495 | login_as :quentin | ||
| 496 | |||
| 497 | get :chapters, params: { :kinds => "erfa" } | ||
| 498 | assert_includes assigns(:nodes), erfa_node | ||
| 499 | assert_not_includes assigns(:nodes), chaostreff_node | ||
| 500 | |||
| 501 | get :chapters | ||
| 502 | assert_includes assigns(:nodes), erfa_node | ||
| 503 | assert_includes assigns(:nodes), chaostreff_node | ||
| 504 | end | ||
| 505 | |||
| 506 | test "recent combined with a search term does not raise an ambiguous column error" do | ||
| 507 | login_as :quentin | ||
| 508 | get :recent, params: { :q => "Zombies" } | ||
| 509 | assert_response :success | ||
| 510 | end | ||
| 511 | |||
| 512 | test "drafts combined with a search term does not raise an ambiguous column error" do | ||
| 513 | login_as :quentin | ||
| 514 | get :drafts, params: { :q => "Zombies" } | ||
| 515 | assert_response :success | ||
| 516 | end | ||
| 517 | |||
| 518 | test "mine combined with a search term does not raise an ambiguous column error" do | ||
| 519 | login_as :quentin | ||
| 520 | get :mine, params: { :q => "Zombies" } | ||
| 521 | assert_response :success | ||
| 522 | end | ||
| 523 | |||
| 524 | test "chapters combined with a search term does not raise an ambiguous column error" do | ||
| 525 | login_as :quentin | ||
| 526 | get :chapters, params: { :q => "Zombies" } | ||
| 527 | assert_response :success | ||
| 528 | end | ||
| 529 | |||
| 530 | test "tags path filters by an arbitrary raw tag, generalizing chapters" do | ||
| 531 | presse_node = Node.root.children.create!(:slug => "tags_path_presse_test") | ||
| 532 | presse_node.find_or_create_draft(@user1) | ||
| 533 | presse_node.draft.tag_list = "pressemitteilung" | ||
| 534 | presse_node.draft.save! | ||
| 535 | presse_node.publish_draft! | ||
| 536 | |||
| 537 | erfa_node = Node.root.children.create!(:slug => "tags_path_erfa_test") | ||
| 538 | erfa_node.find_or_create_draft(@user1) | ||
| 539 | erfa_node.draft.tag_list = "erfa-detail" | ||
| 540 | erfa_node.draft.save! | ||
| 541 | erfa_node.publish_draft! | ||
| 542 | |||
| 543 | login_as :quentin | ||
| 544 | get :tags, params: { :tags => "pressemitteilung" } | ||
| 545 | |||
| 546 | assert_includes assigns(:nodes), presse_node | ||
| 547 | assert_not_includes assigns(:nodes), erfa_node | ||
| 548 | |||
| 549 | assert_select "h1", "Nodes tagged: pressemitteilung" | ||
| 550 | assert_select "h1", :text => "Chapters", :count => 0 | ||
| 551 | end | ||
| 552 | |||
| 553 | test "tags path with multiple tags matches any of them, not all" do | ||
| 554 | erfa_node = Node.root.children.create!(:slug => "tags_path_multi_erfa_test") | ||
| 555 | erfa_node.find_or_create_draft(@user1) | ||
| 556 | erfa_node.draft.tag_list = "erfa-detail" | ||
| 557 | erfa_node.draft.save! | ||
| 558 | erfa_node.publish_draft! | ||
| 559 | |||
| 560 | chaostreff_node = Node.root.children.create!(:slug => "tags_path_multi_chaostreff_test") | ||
| 561 | chaostreff_node.find_or_create_draft(@user1) | ||
| 562 | chaostreff_node.draft.tag_list = "chaostreff-detail" | ||
| 563 | chaostreff_node.draft.save! | ||
| 564 | chaostreff_node.publish_draft! | ||
| 565 | |||
| 566 | login_as :quentin | ||
| 567 | get :tags, params: {:tags => "erfa-detail,chaostreff-detail" } | ||
| 568 | |||
| 569 | assert_includes assigns(:nodes), erfa_node | ||
| 570 | assert_includes assigns(:nodes), chaostreff_node | ||
| 571 | end | ||
| 572 | |||
| 573 | test "chapters renders the curated heading" do | ||
| 574 | login_as :quentin | ||
| 575 | get :chapters | ||
| 576 | assert_select "h1", "Chapters" | ||
| 577 | end | ||
| 474 | end | 578 | end |
