Skip to content

Commit ea5df41

Browse files
committed
Auto-RSVP attendees to Mystery Activity via slug allowlist
Mystery Activity is part of the main Thursday programming but has kind: community, so it doesn't fit DEFAULT_PLAN_KINDS. Add a DEFAULT_PLAN_SLUGS allowlist (initially %w[thu-mystery]) and union it into the default_plan scope so the Mystery Activity is auto-added to every user's plan without sweeping in the other community items (Pre-Conference Meetup, Roundtable, Hack Day) that should remain opt-in. Run bin/rails plan:backfill_defaults again on existing environments to add the Mystery Activity to existing users.
1 parent ad1c8e3 commit ea5df41

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎app/models/schedule_item.rb‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
class ScheduleItem < ApplicationRecord
22
EMBASSY_MODES = %w[new_passport stamping passport_pickup].freeze
33
DEFAULT_PLAN_KINDS = %w[talk reception].freeze
4+
# One-off slugs that don't fit a default-plan kind but are still part of
5+
# the main programming every attendee is auto-RSVPed to.
6+
DEFAULT_PLAN_SLUGS = %w[thu-mystery].freeze
47

58
belongs_to :created_by, class_name: "User", optional: true
69
has_many :plan_items, dependent: :destroy
@@ -69,9 +72,13 @@ class ScheduleItem < ApplicationRecord
6972
scope :volunteer_empty, -> { volunteer.where.missing(:plan_items) }
7073
# Items every attendee is auto-RSVPed to on signup (and via the backfill
7174
# task). Restricted to public, audience: "everyone" so volunteer-only items
72-
# are never auto-added to attendees' plans.
75+
# are never auto-added to attendees' plans. Matches by kind OR by an
76+
# explicit allowlist of slugs (for one-off items that don't fit a kind).
7377
scope :default_plan, -> {
74-
public_items.where(audience: "everyone", kind: kinds.values_at(*DEFAULT_PLAN_KINDS))
78+
public_items.where(audience: "everyone")
79+
.where("kind IN (?) OR slug IN (?)",
80+
kinds.values_at(*DEFAULT_PLAN_KINDS),
81+
DEFAULT_PLAN_SLUGS)
7582
}
7683

7784
# Creators always get auto-added to their own plan — whether the item is

‎test/models/user_test.rb‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ class UserTest < ActiveSupport::TestCase
5454
assert_not_includes user.planned_schedule_items, volunteers_only_reception, "volunteers_only items should not be auto-added to attendees"
5555
end
5656

57+
test "new user is auto-RSVPed to slug-allowlisted items even when kind isn't a default" do
58+
mystery = ScheduleItem.create!(
59+
slug: "thu-mystery", day: "thu", title: "Mystery Activity",
60+
kind: :community, is_public: true
61+
)
62+
other_community = ScheduleItem.create!(
63+
slug: "wed-meetup", day: "wed", title: "Pre-Conference Meetup",
64+
kind: :community, is_public: true
65+
)
66+
67+
user = User.create!(email: "mystery@example.com", first_name: "M", last_name: "Y")
68+
69+
assert_includes user.planned_schedule_items, mystery, "slug-allowlisted item should be auto-added"
70+
assert_not_includes user.planned_schedule_items, other_community, "other community items should not auto-add"
71+
end
72+
5773
test "materialize_default_plan_items is idempotent" do
5874
ScheduleItem.create!(day: "thu", title: "Default Talk", kind: :talk, is_public: true)
5975
user = User.create!(email: "idem@example.com", first_name: "I", last_name: "D")

0 commit comments

Comments
 (0)