diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/controllers/admin_controller_test.rb | 20 | ||||
| -rw-r--r-- | test/controllers/nodes_controller_test.rb | 20 | ||||
| -rw-r--r-- | test/models/node_test.rb | 24 |
3 files changed, 44 insertions, 20 deletions
diff --git a/test/controllers/admin_controller_test.rb b/test/controllers/admin_controller_test.rb index 9beaf58..00a51e2 100644 --- a/test/controllers/admin_controller_test.rb +++ b/test/controllers/admin_controller_test.rb | |||
| @@ -15,26 +15,6 @@ class AdminControllerTest < ActionController::TestCase | |||
| 15 | assert_includes assigns(:drafts), node | 15 | assert_includes assigns(:drafts), node |
| 16 | end | 16 | end |
| 17 | 17 | ||
| 18 | test "my work list shows each matching node only once, even with several revisions by the same user" do | ||
| 19 | login_as :quentin | ||
| 20 | user = User.find_by_login("quentin") | ||
| 21 | node = Node.root.children.create!(:slug => "dedup_test") | ||
| 22 | node.lock_for_editing!(user) | ||
| 23 | node.autosave!({:title => "v1"}, user) | ||
| 24 | node.save_draft!(user) | ||
| 25 | node.publish_draft! | ||
| 26 | node.lock_for_editing!(user) | ||
| 27 | node.autosave!({:title => "v2"}, user) | ||
| 28 | node.save_draft!(user) | ||
| 29 | node.publish_draft! | ||
| 30 | # three pages now exist on this node, all touched by quentin -- | ||
| 31 | # without DISTINCT, the join would return this node three times | ||
| 32 | |||
| 33 | get :index | ||
| 34 | matches = assigns(:mynodes).select { |n| n.id == node.id } | ||
| 35 | assert_equal 1, matches.length | ||
| 36 | end | ||
| 37 | |||
| 38 | test "dashboard_search returns matching tags and nodes grouped separately" do | 18 | test "dashboard_search returns matching tags and nodes grouped separately" do |
| 39 | node = Node.root.children.create!(:slug => "dashboard_search_test") | 19 | node = Node.root.children.create!(:slug => "dashboard_search_test") |
| 40 | node.find_or_create_draft(User.find_by_login("aaron")) | 20 | node.find_or_create_draft(User.find_by_login("aaron")) |
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index b43d2de..81e3f45 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb | |||
| @@ -521,6 +521,26 @@ class NodesControllerTest < ActionController::TestCase | |||
| 521 | assert_response :success | 521 | assert_response :success |
| 522 | end | 522 | end |
| 523 | 523 | ||
| 524 | test "mine shows each matching node only once, even with several revisions by the same user" do | ||
| 525 | login_as :quentin | ||
| 526 | user = User.find_by_login("quentin") | ||
| 527 | node = Node.root.children.create!(:slug => "dedup_test") | ||
| 528 | node.lock_for_editing!(user) | ||
| 529 | node.autosave!({:title => "v1"}, user) | ||
| 530 | node.save_draft!(user) | ||
| 531 | node.publish_draft! | ||
| 532 | node.lock_for_editing!(user) | ||
| 533 | node.autosave!({:title => "v2"}, user) | ||
| 534 | node.save_draft!(user) | ||
| 535 | node.publish_draft! | ||
| 536 | # three pages now exist on this node, all touched by quentin -- | ||
| 537 | # without DISTINCT, the join would return this node three times | ||
| 538 | |||
| 539 | get :mine | ||
| 540 | matches = assigns(:nodes).select { |n| n.id == node.id } | ||
| 541 | assert_equal 1, matches.length | ||
| 542 | end | ||
| 543 | |||
| 524 | test "chapters combined with a search term does not raise an ambiguous column error" do | 544 | test "chapters combined with a search term does not raise an ambiguous column error" do |
| 525 | login_as :quentin | 545 | login_as :quentin |
| 526 | get :chapters, params: { :q => "Zombies" } | 546 | get :chapters, params: { :q => "Zombies" } |
diff --git a/test/models/node_test.rb b/test/models/node_test.rb index de540f8..0bce222 100644 --- a/test/models/node_test.rb +++ b/test/models/node_test.rb | |||
| @@ -561,4 +561,28 @@ class NodeTest < ActiveSupport::TestCase | |||
| 561 | result = Node.drafts_and_autosaves(current_user_id: @user1.id).to_a | 561 | result = Node.drafts_and_autosaves(current_user_id: @user1.id).to_a |
| 562 | assert result.index(mine) < result.index(someone_elses_newer) | 562 | assert result.index(mine) < result.index(someone_elses_newer) |
| 563 | end | 563 | end |
| 564 | |||
| 565 | test "recently_changed includes a node whose head was recently published" do | ||
| 566 | node = Node.root.children.create!(:slug => "recent_changed_published") | ||
| 567 | node.find_or_create_draft(@user1) | ||
| 568 | node.autosave!({:title => "v1"}, @user1) | ||
| 569 | node.save_draft!(@user1) | ||
| 570 | node.publish_draft! | ||
| 571 | |||
| 572 | assert_includes Node.recently_changed, node | ||
| 573 | end | ||
| 574 | |||
| 575 | test "recently_changed excludes a node only touched by locking or unlocking after an old publish" do | ||
| 576 | node = Node.root.children.create!(:slug => "recent_changed_lock_only") | ||
| 577 | node.find_or_create_draft(@user1) | ||
| 578 | node.autosave!({:title => "v1"}, @user1) | ||
| 579 | node.save_draft!(@user1) | ||
| 580 | node.publish_draft! | ||
| 581 | node.head.update_column(:updated_at, 20.days.ago) | ||
| 582 | |||
| 583 | node.lock_for_editing!(@user1) | ||
| 584 | node.unlock! | ||
| 585 | |||
| 586 | assert_not_includes Node.recently_changed, node | ||
| 587 | end | ||
| 564 | end | 588 | end |
