diff options
Diffstat (limited to 'test/controllers/nodes_controller_test.rb')
| -rw-r--r-- | test/controllers/nodes_controller_test.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index 05cb195..b43d2de 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb | |||
| @@ -575,4 +575,56 @@ class NodesControllerTest < ActionController::TestCase | |||
| 575 | get :chapters | 575 | get :chapters |
| 576 | assert_select "h1", "Chapters" | 576 | assert_select "h1", "Chapters" |
| 577 | end | 577 | end |
| 578 | |||
| 579 | test "sitemap collapses configured paths but leaves others open" do | ||
| 580 | club = Node.root.children.create!(:slug => "club") | ||
| 581 | erfas = club.children.create!(:slug => "erfas") | ||
| 582 | erfas.children.create!(:slug => "one_chapter") | ||
| 583 | other = Node.root.children.create!(:slug => "sitemap_controller_open_test") | ||
| 584 | other.children.create!(:slug => "sitemap_controller_open_child") | ||
| 585 | |||
| 586 | login_as :quentin | ||
| 587 | get :sitemap | ||
| 588 | assert_response :success | ||
| 589 | |||
| 590 | doc = Nokogiri::HTML::DocumentFragment.parse(response.body) | ||
| 591 | |||
| 592 | erfas_node_div = doc.css('.sitemap_node').find { |div| div.at_css('.field_hint')&.text&.include?(erfas.unique_name) } | ||
| 593 | other_node_div = doc.css('.sitemap_node').find { |div| div.at_css('.field_hint')&.text&.include?(other.unique_name) } | ||
| 594 | |||
| 595 | erfas_details = erfas_node_div.next_element | ||
| 596 | other_details = other_node_div.next_element | ||
| 597 | |||
| 598 | assert_equal 'details', erfas_details.name | ||
| 599 | assert_equal 'details', other_details.name | ||
| 600 | assert_not erfas_details.key?('open') | ||
| 601 | assert other_details.key?('open') | ||
| 602 | end | ||
| 603 | |||
| 604 | test "sitemap shows how many descendants a collapsed branch is hiding" do | ||
| 605 | club = Node.root.children.create!(:slug => "club") | ||
| 606 | erfas = club.children.create!(:slug => "erfas") | ||
| 607 | erfas.children.create!(:slug => "one_chapter") | ||
| 608 | erfas.children.create!(:slug => "another_chapter") | ||
| 609 | |||
| 610 | login_as :quentin | ||
| 611 | get :sitemap | ||
| 612 | assert_response :success | ||
| 613 | |||
| 614 | doc = Nokogiri::HTML::DocumentFragment.parse(response.body) | ||
| 615 | erfas_node_div = doc.css('.sitemap_node').find { |div| div.at_css('.field_hint')&.text&.include?(erfas.unique_name) } | ||
| 616 | erfas_details = erfas_node_div.next_element | ||
| 617 | |||
| 618 | assert_equal 'details', erfas_details.name | ||
| 619 | assert_match "2 descendants", erfas_details.at_css('summary').text | ||
| 620 | end | ||
| 621 | |||
| 622 | test "sitemap shows Show and Create Child, not Revisions" do | ||
| 623 | node = Node.root.children.create!(:slug => "sitemap_actions_test") | ||
| 624 | login_as :quentin | ||
| 625 | get :sitemap | ||
| 626 | assert_select ".sitemap_node_actions", :text => /Show/ | ||
| 627 | assert_select ".sitemap_node_actions", :text => /Create Child/ | ||
| 628 | assert_select ".sitemap_node_actions", :text => /Revisions/, :count => 0 | ||
| 629 | end | ||
| 578 | end | 630 | end |
