From 4a8e475f5864f6564cfecf2059c3d8a96873f5f8 Mon Sep 17 00:00:00 2001 From: Katya Sarmiento <5871075+Kitkatnik@users.noreply.github.com> Date: Mon, 27 Apr 2026 15:08:29 -0400 Subject: [PATCH] Admin user show: hide talks and receptions from plan list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users are auto-RSVPed to talks and receptions on signup, so listing them under "On their plan" hides the only signal admins want — the extra activities a user explicitly opted into. Filter using ScheduleItem's DEFAULT_PLAN_KINDS constant so this view stays aligned with the auto-RSVP source of truth. --- app/controllers/admin/users_controller.rb | 4 ++- .../admin/users_controller_test.rb | 32 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 9573fab..1ed9be4 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -47,7 +47,9 @@ def show ] } @embassy_plan_items = all_plan_items.select { |pi| pi.schedule_item.embassy? } - @other_plan_items = all_plan_items - @embassy_plan_items + @other_plan_items = all_plan_items.reject do |pi| + pi.schedule_item.embassy? || ScheduleItem::DEFAULT_PLAN_KINDS.include?(pi.schedule_item.kind) + end # "Hosting" = any schedule_item whose host string matches this user's # full_name. Catches both admin-dropdown assignments and user-created diff --git a/test/controllers/admin/users_controller_test.rb b/test/controllers/admin/users_controller_test.rb index 3d49400..13f114f 100644 --- a/test/controllers/admin/users_controller_test.rb +++ b/test/controllers/admin/users_controller_test.rb @@ -19,8 +19,8 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest alice = users(:attendee_one) item = ScheduleItem.create!( day: "fri", - title: "Alice planned talk", - kind: :talk, + title: "Alice planned activity", + kind: :activity, is_public: true, time_label: "10:00 AM", sort_time: 1000 @@ -29,7 +29,33 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest sign_in_as users(:jeremy) get admin_user_path(alice) - assert_match "Alice planned talk", response.body + assert_match "Alice planned activity", response.body + end + + test "admin show page hides talks and receptions from the plan section" do + alice = users(:attendee_one) + talk = ScheduleItem.create!( + day: "fri", title: "Default Talk", kind: :talk, + is_public: true, time_label: "10:00 AM", sort_time: 1000 + ) + reception = ScheduleItem.create!( + day: "fri", title: "Default Reception", kind: :reception, + is_public: true, time_label: "6:00 PM", sort_time: 1800 + ) + activity = ScheduleItem.create!( + day: "sat", title: "Optional Activity", kind: :activity, + is_public: true, time_label: "2:00 PM", sort_time: 1400 + ) + alice.plan_items.create!(schedule_item: talk) + alice.plan_items.create!(schedule_item: reception) + alice.plan_items.create!(schedule_item: activity) + + sign_in_as users(:jeremy) + get admin_user_path(alice) + assert_response :success + assert_match "Optional Activity", response.body + assert_no_match(/Default Talk/, response.body) + assert_no_match(/Default Reception/, response.body) end test "admin users index links to each user's show page" do