summaryrefslogtreecommitdiff
path: root/test/controllers/admin_controller_test.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-13 23:33:11 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-13 23:33:11 +0200
commit8eab68f2c5a3c126e2fec2ecdfa7ace87ce0937b (patch)
treef446ebc26a7707c7b64a937aa51a155df146c80a /test/controllers/admin_controller_test.rb
parent42714c697273a7117c6b355fab26c8c35e336ad1 (diff)
parentcdf5d9941ca866d437612d2f863eac6eb0b3db12 (diff)
Merge branch 'erdgeist-revive-events'
Diffstat (limited to 'test/controllers/admin_controller_test.rb')
-rw-r--r--test/controllers/admin_controller_test.rb39
1 files changed, 36 insertions, 3 deletions
diff --git a/test/controllers/admin_controller_test.rb b/test/controllers/admin_controller_test.rb
index 9bbf29b..00a51e2 100644
--- a/test/controllers/admin_controller_test.rb
+++ b/test/controllers/admin_controller_test.rb
@@ -1,8 +1,41 @@
1require 'test_helper' 1require 'test_helper'
2 2
3class AdminControllerTest < ActionController::TestCase 3class AdminControllerTest < ActionController::TestCase
4 # Replace this with your real tests. 4 test "current drafts includes nodes with only an autosave" do
5 test "the truth" do 5 node = Node.root.children.create!(:slug => "admin_autosave_only")
6 assert true 6 node.lock_for_editing!(User.find_by_login("aaron"))
7 node.autosave!({title: "in progress"}, User.find_by_login("aaron"))
8 node.save_draft!(User.find_by_login("aaron"))
9 node.publish_draft!
10 node.lock_for_editing!(User.find_by_login("aaron"))
11 node.autosave!({title: "editing again"}, User.find_by_login("aaron"))
12
13 login_as :quentin
14 get :index
15 assert_includes assigns(:drafts), node
16 end
17
18 test "dashboard_search returns matching tags and nodes grouped separately" do
19 node = Node.root.children.create!(:slug => "dashboard_search_test")
20 node.find_or_create_draft(User.find_by_login("aaron"))
21 node.draft.update(:title => "Biometrics Workshop")
22 node.draft.tag_list = "biometrics-workshop"
23 node.draft.save!
24
25 login_as :quentin
26 get :dashboard_search, params: { :search_term => "biometr" }, :format => :json
27
28 json = JSON.parse(response.body)
29 assert json["tags"].any? { |t| t["name"] == "biometrics-workshop" }
30 assert json["nodes"].any? { |n| n["title"] == "Biometrics Workshop" }
31 end
32
33 test "dashboard_search returns empty results for a blank term" do
34 login_as :quentin
35 get :dashboard_search, params: { :search_term => "" }, :format => :json
36
37 json = JSON.parse(response.body)
38 assert_equal [], json["tags"]
39 assert_equal [], json["nodes"]
7 end 40 end
8end 41end