diff options
Diffstat (limited to 'test/controllers/nodes_controller_test.rb')
| -rw-r--r-- | test/controllers/nodes_controller_test.rb | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index b563d4d..05cb195 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb | |||
| @@ -471,4 +471,108 @@ class NodesControllerTest < ActionController::TestCase | |||
| 471 | assert_response :success | 471 | assert_response :success |
| 472 | assert_select "form.destructive", :count => 0 | 472 | assert_select "form.destructive", :count => 0 |
| 473 | end | 473 | end |
| 474 | |||
| 475 | test "drafts includes a never-published node with only a draft" do | ||
| 476 | node = Node.root.children.create!(:slug => "drafts_action_test") | ||
| 477 | login_as :quentin | ||
| 478 | get :drafts | ||
| 479 | assert_includes assigns(:nodes), node | ||
| 480 | end | ||
| 481 | |||
| 482 | test "chapters filters by kind, matching head or draft, and shows both by default" do | ||
| 483 | erfa_node = Node.root.children.create!(:slug => "chapters_erfa_test") | ||
| 484 | erfa_node.find_or_create_draft(@user1) | ||
| 485 | erfa_node.draft.tag_list = "erfa-detail" | ||
| 486 | erfa_node.draft.save! | ||
| 487 | erfa_node.publish_draft! | ||
| 488 | |||
| 489 | chaostreff_node = Node.root.children.create!(:slug => "chapters_chaostreff_test") | ||
| 490 | chaostreff_node.find_or_create_draft(@user1) | ||
| 491 | chaostreff_node.draft.tag_list = "chaostreff-detail" | ||
| 492 | chaostreff_node.draft.save! | ||
| 493 | chaostreff_node.publish_draft! | ||
| 494 | |||
| 495 | login_as :quentin | ||
| 496 | |||
| 497 | get :chapters, params: { :kinds => "erfa" } | ||
| 498 | assert_includes assigns(:nodes), erfa_node | ||
| 499 | assert_not_includes assigns(:nodes), chaostreff_node | ||
| 500 | |||
| 501 | get :chapters | ||
| 502 | assert_includes assigns(:nodes), erfa_node | ||
| 503 | assert_includes assigns(:nodes), chaostreff_node | ||
| 504 | end | ||
| 505 | |||
| 506 | test "recent combined with a search term does not raise an ambiguous column error" do | ||
| 507 | login_as :quentin | ||
| 508 | get :recent, params: { :q => "Zombies" } | ||
| 509 | assert_response :success | ||
| 510 | end | ||
| 511 | |||
| 512 | test "drafts combined with a search term does not raise an ambiguous column error" do | ||
| 513 | login_as :quentin | ||
| 514 | get :drafts, params: { :q => "Zombies" } | ||
| 515 | assert_response :success | ||
| 516 | end | ||
| 517 | |||
| 518 | test "mine combined with a search term does not raise an ambiguous column error" do | ||
| 519 | login_as :quentin | ||
| 520 | get :mine, params: { :q => "Zombies" } | ||
| 521 | assert_response :success | ||
| 522 | end | ||
| 523 | |||
| 524 | test "chapters combined with a search term does not raise an ambiguous column error" do | ||
| 525 | login_as :quentin | ||
| 526 | get :chapters, params: { :q => "Zombies" } | ||
| 527 | assert_response :success | ||
| 528 | end | ||
| 529 | |||
| 530 | test "tags path filters by an arbitrary raw tag, generalizing chapters" do | ||
| 531 | presse_node = Node.root.children.create!(:slug => "tags_path_presse_test") | ||
| 532 | presse_node.find_or_create_draft(@user1) | ||
| 533 | presse_node.draft.tag_list = "pressemitteilung" | ||
| 534 | presse_node.draft.save! | ||
| 535 | presse_node.publish_draft! | ||
| 536 | |||
| 537 | erfa_node = Node.root.children.create!(:slug => "tags_path_erfa_test") | ||
| 538 | erfa_node.find_or_create_draft(@user1) | ||
| 539 | erfa_node.draft.tag_list = "erfa-detail" | ||
| 540 | erfa_node.draft.save! | ||
| 541 | erfa_node.publish_draft! | ||
| 542 | |||
| 543 | login_as :quentin | ||
| 544 | get :tags, params: { :tags => "pressemitteilung" } | ||
| 545 | |||
| 546 | assert_includes assigns(:nodes), presse_node | ||
| 547 | assert_not_includes assigns(:nodes), erfa_node | ||
| 548 | |||
| 549 | assert_select "h1", "Nodes tagged: pressemitteilung" | ||
| 550 | assert_select "h1", :text => "Chapters", :count => 0 | ||
| 551 | end | ||
| 552 | |||
| 553 | test "tags path with multiple tags matches any of them, not all" do | ||
| 554 | erfa_node = Node.root.children.create!(:slug => "tags_path_multi_erfa_test") | ||
| 555 | erfa_node.find_or_create_draft(@user1) | ||
| 556 | erfa_node.draft.tag_list = "erfa-detail" | ||
| 557 | erfa_node.draft.save! | ||
| 558 | erfa_node.publish_draft! | ||
| 559 | |||
| 560 | chaostreff_node = Node.root.children.create!(:slug => "tags_path_multi_chaostreff_test") | ||
| 561 | chaostreff_node.find_or_create_draft(@user1) | ||
| 562 | chaostreff_node.draft.tag_list = "chaostreff-detail" | ||
| 563 | chaostreff_node.draft.save! | ||
| 564 | chaostreff_node.publish_draft! | ||
| 565 | |||
| 566 | login_as :quentin | ||
| 567 | get :tags, params: {:tags => "erfa-detail,chaostreff-detail" } | ||
| 568 | |||
| 569 | assert_includes assigns(:nodes), erfa_node | ||
| 570 | assert_includes assigns(:nodes), chaostreff_node | ||
| 571 | end | ||
| 572 | |||
| 573 | test "chapters renders the curated heading" do | ||
| 574 | login_as :quentin | ||
| 575 | get :chapters | ||
| 576 | assert_select "h1", "Chapters" | ||
| 577 | end | ||
| 474 | end | 578 | end |
