diff options
Diffstat (limited to 'test/controllers/admin_controller_test.rb')
| -rw-r--r-- | test/controllers/admin_controller_test.rb | 39 |
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 @@ | |||
| 1 | require 'test_helper' | 1 | require 'test_helper' |
| 2 | 2 | ||
| 3 | class AdminControllerTest < ActionController::TestCase | 3 | class 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 |
| 8 | end | 41 | end |
