diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-04 01:24:55 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-04 01:24:55 +0200 |
| commit | 206dc5c50a73c5402b90d7fdc8945d3ba9356758 (patch) | |
| tree | b2c98c48248c878da4344e61734bfa89130f18d1 /test/controllers/nodes_controller_test.rb | |
| parent | d9461bae0b6232d618dde118360b44bb80f962b8 (diff) | |
Add self-service event creation from nodes#show
nodes#show's events table now renders unconditionally (previously
hidden entirely for a zero-event node) and gains an "add event" link.
The suggested tag_list is derived from the page's own category tags
via NodesHelper::DEFAULT_EVENT_TAG_BY_PAGE_TAG (erfa-detail/
chaostreff-detail -> open-day) rather than hardcoded, and degrades to
a blank field for any node whose tags don't match - deliberately
universal, not chapter-specific, since Updates have historically
carried event dates the same way.
events#new surfaces *why* the tag was pre-filled via flash.now (not
flash - this is a same-request render, not a redirect), using an
explicit auto_tag_source param passed alongside tag_list rather than
having the controller re-derive the reason from node_id.
No destroy link added to nodes#show's events list - deliberate, per
existing subnav-semantics convention (destructive actions live on the
resource's own views). Covered directly by test.
Adds real coverage for EventsController, previously 100% commented-out
scaffold, plus unit tests for the new tag-mapping helper and the
weekday-abbreviation helpers from the prior commit.
Diffstat (limited to 'test/controllers/nodes_controller_test.rb')
| -rw-r--r-- | test/controllers/nodes_controller_test.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index 53799f1..f14e27c 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb | |||
| @@ -379,4 +379,37 @@ class NodesControllerTest < ActionController::TestCase | |||
| 379 | get :index | 379 | get :index |
| 380 | end | 380 | end |
| 381 | 381 | ||
| 382 | test "show renders events row and add-link for zero-event chapter node" do | ||
| 383 | login_as :quentin | ||
| 384 | node = create_node_with_published_page | ||
| 385 | node.head.tag_list = "erfa-detail" | ||
| 386 | node.head.save! | ||
| 387 | |||
| 388 | get :show, params: { id: node.id } | ||
| 389 | assert_response :success | ||
| 390 | assert_select "a", text: "add event" | ||
| 391 | assert_select "a[href*='tag_list=open-day']" | ||
| 392 | assert_select "a[href*='auto_tag_source=erfa-detail']" | ||
| 393 | end | ||
| 394 | |||
| 395 | test "show renders events row without a tag default for untagged node" do | ||
| 396 | login_as :quentin | ||
| 397 | node = create_node_with_published_page | ||
| 398 | |||
| 399 | get :show, params: { id: node.id } | ||
| 400 | assert_response :success | ||
| 401 | assert_select "a", text: "add event" | ||
| 402 | assert_select "a[href*='tag_list=']", count: 0 | ||
| 403 | end | ||
| 404 | |||
| 405 | test "show never renders a destroy link for events" do | ||
| 406 | login_as :quentin | ||
| 407 | node = create_node_with_published_page | ||
| 408 | Event.create!(node_id: node.id, start_time: Time.now, end_time: Time.now + 1.hour) | ||
| 409 | |||
| 410 | get :show, params: { id: node.id } | ||
| 411 | assert_response :success | ||
| 412 | assert_select "form.button_to.destructive", count: 0 | ||
| 413 | end | ||
| 414 | |||
| 382 | end | 415 | end |
