From 33fb371fdc5473fc0e8b357a633ce657ea78c15a Mon Sep 17 00:00:00 2001 From: Katya Sarmiento <5871075+Kitkatnik@users.noreply.github.com> Date: Thu, 30 Apr 2026 11:10:22 -0400 Subject: [PATCH] Admin schedule: pair host_url with host so speaker links don't drift The admin form let admins change a talk's host name via the dropdown, but had no field for host_url and didn't permit it in strong params. Editing a talk's host left host_url pointing at the previous speaker's profile, so the rendered name and link disagreed in production. Add a Speaker profile URL field next to the host dropdown (mirroring :map_url) and permit :host_url in schedule_item_params. Add regression tests for both the form field and the update round-trip. --- .../admin/schedule_items_controller.rb | 2 +- app/views/admin/schedule_items/_form.html.erb | 10 ++++++ .../admin/schedule_items_controller_test.rb | 31 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/schedule_items_controller.rb b/app/controllers/admin/schedule_items_controller.rb index c17aaa4..9281092 100644 --- a/app/controllers/admin/schedule_items_controller.rb +++ b/app/controllers/admin/schedule_items_controller.rb @@ -84,7 +84,7 @@ def safe_return_to # config/schedule.yml items and should never be set by hand. def schedule_item_params attrs = params.require(:schedule_item).permit( - :day, :time_label, :sort_time, :title, :host, + :day, :time_label, :sort_time, :title, :host, :host_url, :location, :map_url, :description, :kind, :flexible, :is_public, :audience, :offers_new_passport, :offers_stamping, :offers_passport_pickup, :new_passport_capacity, :stamping_capacity, :passport_pickup_capacity, diff --git a/app/views/admin/schedule_items/_form.html.erb b/app/views/admin/schedule_items/_form.html.erb index f0297ea..e88e3a5 100644 --- a/app/views/admin/schedule_items/_form.html.erb +++ b/app/views/admin/schedule_items/_form.html.erb @@ -71,6 +71,16 @@ class: "select" %> +
+ <%= f.label :host_url, "Speaker profile URL", class: "label" %> + <%= f.url_field :host_url, class: "input", + placeholder: "https://blueridgeruby.com/speakers/..." %> +

+ Optional. If set, the speaker's name links to this URL on /schedule and /plan. + Update this whenever you change the host so the link points to the right person. +

+
+
<%= f.label :location, class: "label" %> <%= f.text_field :location, class: "input" %> diff --git a/test/controllers/admin/schedule_items_controller_test.rb b/test/controllers/admin/schedule_items_controller_test.rb index 6520966..fbc1ed0 100644 --- a/test/controllers/admin/schedule_items_controller_test.rb +++ b/test/controllers/admin/schedule_items_controller_test.rb @@ -134,6 +134,37 @@ def valid_form_params(overrides = {}) end end + test "admin edit form exposes a host_url field so name and link stay paired" do + item = ScheduleItem.create!( + day: "thu", title: "Keynote", host: "John Athayde", + host_url: "https://blueridgeruby.com/speakers/john-athayde/", + kind: :talk, is_public: true + ) + sign_in_as users(:jeremy) + get edit_admin_schedule_item_path(item) + + assert_select "input[name='schedule_item[host_url]'][value=?]", + "https://blueridgeruby.com/speakers/john-athayde/" + end + + test "admin update persists host_url alongside host" do + item = ScheduleItem.create!( + day: "thu", title: "Keynote", host: "John Athayde", + host_url: "https://blueridgeruby.com/speakers/john-athayde/", + kind: :talk, is_public: true + ) + sign_in_as users(:jeremy) + + patch admin_schedule_item_path(item), params: valid_form_params( + title: "Keynote", host: "Joël Quenneville", + host_url: "https://blueridgeruby.com/speakers/joel-quenneville/" + ) + + item.reload + assert_equal "Joël Quenneville", item.host + assert_equal "https://blueridgeruby.com/speakers/joel-quenneville/", item.host_url + end + test "admin can create a volunteers_only public item" do sign_in_as users(:jeremy) post admin_schedule_items_path, params: valid_form_params(