diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-12 16:33:12 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-12 16:33:12 +0200 |
| commit | 4ec70e5ecf792a56e868538738d6c7f63bb6cf24 (patch) | |
| tree | 45364f298ce21a7e47de619b7db79b9b77e4ebc1 /test/controllers/admin_controller_test.rb | |
| parent | 5803c59192b7fb05840d0b452eb64d9f997f3d8f (diff) | |
Add a grouped tag+node search endpoint for the upcoming dashboard
AdminController#dashboard_search returns tags and nodes as separate,
labeled groups (via ActsAsTaggableOn::Tag.named_like and
Node.editor_search) rather than the flat per-node list every existing
picker returns. initSearchPicker gains a renderResults callback option
that, when given, replaces the default per-node rendering entirely --
lets the dashboard render its two labeled groups without a second,
parallel picker implementation.
resultsHeaderHtml (the "Press Enter to see all results" hint) is now
threaded through as a third argument to renderResults, so a picker with
custom rendering can still show it -- previously only the default
per-node branch ever did.
Tags link straight to the existing /admin/nodes/tags/:tag view rather
than becoming an in-place filter chip.
Diffstat (limited to 'test/controllers/admin_controller_test.rb')
| -rw-r--r-- | test/controllers/admin_controller_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/controllers/admin_controller_test.rb b/test/controllers/admin_controller_test.rb index 13cc1bb..9beaf58 100644 --- a/test/controllers/admin_controller_test.rb +++ b/test/controllers/admin_controller_test.rb | |||
| @@ -34,4 +34,28 @@ class AdminControllerTest < ActionController::TestCase | |||
| 34 | matches = assigns(:mynodes).select { |n| n.id == node.id } | 34 | matches = assigns(:mynodes).select { |n| n.id == node.id } |
| 35 | assert_equal 1, matches.length | 35 | assert_equal 1, matches.length |
| 36 | end | 36 | end |
| 37 | |||
| 38 | test "dashboard_search returns matching tags and nodes grouped separately" do | ||
| 39 | node = Node.root.children.create!(:slug => "dashboard_search_test") | ||
| 40 | node.find_or_create_draft(User.find_by_login("aaron")) | ||
| 41 | node.draft.update(:title => "Biometrics Workshop") | ||
| 42 | node.draft.tag_list = "biometrics-workshop" | ||
| 43 | node.draft.save! | ||
| 44 | |||
| 45 | login_as :quentin | ||
| 46 | get :dashboard_search, params: { :search_term => "biometr" }, :format => :json | ||
| 47 | |||
| 48 | json = JSON.parse(response.body) | ||
| 49 | assert json["tags"].any? { |t| t["name"] == "biometrics-workshop" } | ||
| 50 | assert json["nodes"].any? { |n| n["title"] == "Biometrics Workshop" } | ||
| 51 | end | ||
| 52 | |||
| 53 | test "dashboard_search returns empty results for a blank term" do | ||
| 54 | login_as :quentin | ||
| 55 | get :dashboard_search, params: { :search_term => "" }, :format => :json | ||
| 56 | |||
| 57 | json = JSON.parse(response.body) | ||
| 58 | assert_equal [], json["tags"] | ||
| 59 | assert_equal [], json["nodes"] | ||
| 60 | end | ||
| 37 | end | 61 | end |
