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/models | |
| 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/models')
| -rw-r--r-- | test/models/concerns/rrule_humanizer_test.rb | 15 | ||||
| -rw-r--r-- | test/models/helpers/content_helper_test.rb | 4 | ||||
| -rw-r--r-- | test/models/helpers/nodes_helper_test.rb | 21 |
3 files changed, 40 insertions, 0 deletions
diff --git a/test/models/concerns/rrule_humanizer_test.rb b/test/models/concerns/rrule_humanizer_test.rb index 500dbc7..279ff73 100644 --- a/test/models/concerns/rrule_humanizer_test.rb +++ b/test/models/concerns/rrule_humanizer_test.rb | |||
| @@ -81,4 +81,19 @@ class RruleHumanizerTest < ActiveSupport::TestCase | |||
| 81 | test "falls back to english for unknown locale" do | 81 | test "falls back to english for unknown locale" do |
| 82 | assert_equal "Every Tuesday", humanize("FREQ=WEEKLY;BYDAY=TU", :fr) | 82 | assert_equal "Every Tuesday", humanize("FREQ=WEEKLY;BYDAY=TU", :fr) |
| 83 | end | 83 | end |
| 84 | |||
| 85 | test "wday_abbr returns the correct German abbreviation for each day" do | ||
| 86 | monday = Time.parse("2026-07-06") # confirmed Monday | ||
| 87 | assert_equal "Mo", RruleHumanizer.wday_abbr(monday, :de) | ||
| 88 | assert_equal "Di", RruleHumanizer.wday_abbr(monday + 1.day, :de) | ||
| 89 | assert_equal "Mi", RruleHumanizer.wday_abbr(monday + 2.days, :de) | ||
| 90 | assert_equal "Do", RruleHumanizer.wday_abbr(monday + 3.days, :de) | ||
| 91 | assert_equal "Fr", RruleHumanizer.wday_abbr(monday + 4.days, :de) | ||
| 92 | assert_equal "Sa", RruleHumanizer.wday_abbr(monday + 5.days, :de) | ||
| 93 | assert_equal "So", RruleHumanizer.wday_abbr(monday + 6.days, :de) | ||
| 94 | end | ||
| 95 | |||
| 96 | test "wday_abbr falls back to :de for an unrecognized locale" do | ||
| 97 | assert_equal "Mo", RruleHumanizer.wday_abbr(Time.parse("2026-07-06"), :fr) | ||
| 98 | end | ||
| 84 | end | 99 | end |
diff --git a/test/models/helpers/content_helper_test.rb b/test/models/helpers/content_helper_test.rb index 2da82d7..a7ed478 100644 --- a/test/models/helpers/content_helper_test.rb +++ b/test/models/helpers/content_helper_test.rb | |||
| @@ -1,4 +1,8 @@ | |||
| 1 | require 'test_helper' | 1 | require 'test_helper' |
| 2 | 2 | ||
| 3 | class ContentHelperTest < ActionView::TestCase | 3 | class ContentHelperTest < ActionView::TestCase |
| 4 | test "weekday_abbr delegates through the current I18n locale" do | ||
| 5 | I18n.locale = :de | ||
| 6 | assert_equal "Mo", weekday_abbr(Time.parse("2026-07-06")) | ||
| 7 | end | ||
| 4 | end | 8 | end |
diff --git a/test/models/helpers/nodes_helper_test.rb b/test/models/helpers/nodes_helper_test.rb index 13011de..5d91a88 100644 --- a/test/models/helpers/nodes_helper_test.rb +++ b/test/models/helpers/nodes_helper_test.rb | |||
| @@ -1,4 +1,25 @@ | |||
| 1 | require 'test_helper' | 1 | require 'test_helper' |
| 2 | 2 | ||
| 3 | class NodesHelperTest < ActionView::TestCase | 3 | class NodesHelperTest < ActionView::TestCase |
| 4 | FakePage = Struct.new(:tag_list) | ||
| 5 | |||
| 6 | test "default_event_tag_mapping matches erfa-detail" do | ||
| 7 | page = FakePage.new(["erfa-detail"]) | ||
| 8 | assert_equal ["erfa-detail", "open-day"], default_event_tag_mapping(page) | ||
| 9 | end | ||
| 10 | |||
| 11 | test "default_event_tag_mapping matches chaostreff-detail" do | ||
| 12 | page = FakePage.new(["chaostreff-detail"]) | ||
| 13 | assert_equal ["chaostreff-detail", "open-day"], default_event_tag_mapping(page) | ||
| 14 | end | ||
| 15 | |||
| 16 | test "default_event_tag_mapping returns nil for unrelated tags" do | ||
| 17 | page = FakePage.new(["update"]) | ||
| 18 | assert_nil default_event_tag_mapping(page) | ||
| 19 | end | ||
| 20 | |||
| 21 | test "default_event_tag_list is nil without a matching tag" do | ||
| 22 | page = FakePage.new([]) | ||
| 23 | assert_nil default_event_tag_list(page) | ||
| 24 | end | ||
| 4 | end | 25 | end |
