From 4165fe03514cf3f8649b39fbcf685ddff7b03707 Mon Sep 17 00:00:00 2001 From: 1steve78 Date: Mon, 12 Oct 2026 22:08:23 +0530 Subject: [PATCH 1/3] Re-enable Turbo Drive on recipients shout-out form --- app/controllers/events_controller.rb | 2 +- app/views/events/recipients.html.erb | 6 +- spec/requests/events_spec.rb | 3 + spec/system/events_recipient_shoutout_spec.rb | 56 +++++++++++++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 spec/system/events_recipient_shoutout_spec.rb diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 407ac5dcf1..096150ca2a 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -392,7 +392,7 @@ def feature_recipient_shoutout # accurate "locked" warning instead of the generic prompt. (#1944) locked = @event.event_registrations.find_by(id: params[:registration_id])&.editing_locked? message = locked ? "That registrant was transferred out — their registration is locked. Undo the transfer to feature them." : "Choose a recipient to feature." - redirect_to recipients_event_path(@event), alert: message and return + redirect_to recipients_event_path(@event), alert: message, status: :see_other and return end authorize! registration, to: :update? diff --git a/app/views/events/recipients.html.erb b/app/views/events/recipients.html.erb index 934ebdd041..a52cebc449 100644 --- a/app/views/events/recipients.html.erb +++ b/app/views/events/recipients.html.erb @@ -207,7 +207,7 @@ form to add the shout-out text (the toggle is already saved). %> <% if recipient_shoutout_options.any? %> <%= form_with url: feature_recipient_shoutout_event_path(@event), method: :post, - data: { turbo: false }, class: "flex items-center gap-2 print:hidden" do %> + class: "flex items-center gap-2 print:hidden" do %>
<%= select_tag :registration_id, options_for_select(recipient_shoutout_options), @@ -216,7 +216,9 @@ class: "ts-flat w-full bg-white border border-gray-300 rounded-lg px-3 py-2 text-sm focus:ring-fuchsia-500 focus:border-fuchsia-500", data: { searchable_select_target: "select" } %>
- <% end %> diff --git a/spec/requests/events_spec.rb b/spec/requests/events_spec.rb index 3def1c1c66..aa3cd68389 100644 --- a/spec/requests/events_spec.rb +++ b/spec/requests/events_spec.rb @@ -3882,6 +3882,7 @@ def ce_chip_text post feature_recipient_shoutout_event_path(event), params: { registration_id: registration.id } expect(registration.reload.shoutout).to be(true) + expect(response).to have_http_status(:see_other) expect(response).to redirect_to( edit_event_registration_path(registration, return_to: "recipients", anchor: "shout-out") ) @@ -3917,6 +3918,7 @@ def ce_chip_text it "returns to the recipients page with an alert when no recipient is chosen" do post feature_recipient_shoutout_event_path(event), params: { registration_id: "" } + expect(response).to have_http_status(:see_other) expect(response).to redirect_to(recipients_event_path(event)) end @@ -3927,6 +3929,7 @@ def ce_chip_text post feature_recipient_shoutout_event_path(event), params: { registration_id: registration.id } expect(registration.reload.shoutout).to be(false) + expect(response).to have_http_status(:see_other) expect(response).to redirect_to(recipients_event_path(event)) expect(flash[:alert]).to match(/transferred out|locked/i) end diff --git a/spec/system/events_recipient_shoutout_spec.rb b/spec/system/events_recipient_shoutout_spec.rb new file mode 100644 index 0000000000..d6a6bd446e --- /dev/null +++ b/spec/system/events_recipient_shoutout_spec.rb @@ -0,0 +1,56 @@ +require "rails_helper" + +RSpec.describe "Events recipient shout-out form", type: :system, js: true do + let(:admin) { create(:user, :admin) } + let(:event) { create(:event, start_date: 1.month.from_now, end_date: 1.month.from_now + 1.day) } + let(:registration_form) { create(:form, name: "Registration") } + let(:scholarship_form) { create(:form, :scholarship) } + let(:applicant) { create(:person, first_name: "Tara", last_name: "Gallagher") } + let!(:registration) do + create(:event_registration, event: event, registrant: applicant, status: "registered", scholarship_requested: true) + end + + before do + create(:event_form, :registration, event: event, form: registration_form) + create(:event_form, :scholarship, event: event, form: scholarship_form) + sign_in admin + end + + it "features the chosen recipient via Turbo and redirects to their registration edit form" do + visit recipients_event_path(event) + + within("#shout-outs") do + expect(page).to have_button("Add shoutout") + # Select recipient via select_tag / TomSelect wrapper + select applicant.name, from: "registration_id", visible: false + click_button "Add shoutout" + end + + expect(page).to have_current_path( + edit_event_registration_path(registration, return_to: "recipients", anchor: "shout-out") + ) + expect(page).to have_content("Featured on the recipients page — review their shout-out text below.") + expect(registration.reload.shoutout).to be(true) + end + + it "shows a warning alert when submitting without choosing a recipient" do + visit recipients_event_path(event) + + within("#shout-outs") do + click_button "Add shoutout" + end + + expect(page).to have_current_path(recipients_event_path(event)) + expect(page).to have_content("Choose a recipient to feature.") + expect(registration.reload.shoutout).to be(false) + end + + it "disables the submit button while submission is in progress" do + visit recipients_event_path(event) + + within("#shout-outs") do + button = find("button[type='submit']") + expect(button["data-turbo-submits-with"]).to eq("Adding…") + end + end +end From 768886238cc37e5478ee238097265f4904e0808e Mon Sep 17 00:00:00 2001 From: 1steve78 Date: Mon, 12 Oct 2026 22:41:01 +0530 Subject: [PATCH 2/3] Fix system spec setup for recipients shout-out form --- spec/system/events_recipient_shoutout_spec.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/system/events_recipient_shoutout_spec.rb b/spec/system/events_recipient_shoutout_spec.rb index d6a6bd446e..f20dee1c46 100644 --- a/spec/system/events_recipient_shoutout_spec.rb +++ b/spec/system/events_recipient_shoutout_spec.rb @@ -5,6 +5,10 @@ let(:event) { create(:event, start_date: 1.month.from_now, end_date: 1.month.from_now + 1.day) } let(:registration_form) { create(:form, name: "Registration") } let(:scholarship_form) { create(:form, :scholarship) } + let(:existing_recipient) { create(:person, first_name: "Alex", last_name: "Smith", shoutout_text: "Proud to serve.") } + let!(:existing_registration) do + create(:event_registration, event: event, registrant: existing_recipient, status: "registered", scholarship_requested: true, shoutout: true) + end let(:applicant) { create(:person, first_name: "Tara", last_name: "Gallagher") } let!(:registration) do create(:event_registration, event: event, registrant: applicant, status: "registered", scholarship_requested: true) @@ -16,13 +20,17 @@ sign_in admin end + def select_recipient(registration_id) + find("select#registration_id", visible: :all).find("option[value='#{registration_id}']").select_option + page.execute_script("document.getElementById('registration_id')?.tomselect?.setValue('#{registration_id}')") + end + it "features the chosen recipient via Turbo and redirects to their registration edit form" do visit recipients_event_path(event) within("#shout-outs") do expect(page).to have_button("Add shoutout") - # Select recipient via select_tag / TomSelect wrapper - select applicant.name, from: "registration_id", visible: false + select_recipient(registration.id) click_button "Add shoutout" end From 1053517d83f1273b5704a03a0fd9fba3591c6b97 Mon Sep 17 00:00:00 2001 From: 1steve78 Date: Mon, 12 Oct 2026 23:10:37 +0530 Subject: [PATCH 3/3] Preserve shout-out scroll target through Turbo redirects Turbo drops the fragment when following a 303 form redirect, leaving admins at the top of the registration editor. Carry the section target in a query parameter and let the existing reveal controller scroll to it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- AGENTS.md | 2 +- app/controllers/events_controller.rb | 2 +- .../controllers/reveal_section_controller.js | 20 ++++++++++--------- app/views/event_registrations/_form.html.erb | 3 ++- spec/requests/events_spec.rb | 2 +- spec/system/events_recipient_shoutout_spec.rb | 12 +++++++++-- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 401843082a..86672a548e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -425,7 +425,7 @@ end - `print_options` — Print options toggle for analytics - `reminder_preview` — Live-preview the reminder email as the admin composes it on the bulk-reminder page: custom message, subject, and the event-details box toggle (announced to screen readers) - `remote_select` — AJAX-powered select dropdown -- `reveal_section` — Expand a collapsible section and scroll to it when loaded via matching URL hash +- `reveal_section` — Expand a collapsible section and scroll to it when loaded via matching URL hash or `scroll_to` query parameter - `rhino_source` — Rich text editor integration - `scholarship_preview` — Live-preview the scholarship's allocated amount as the edit form changes - `scroll_to_top` — Scrolls the window to the top on connect (used by the duplicate-person warning so it comes into view on create) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 096150ca2a..7d816b1713 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -401,7 +401,7 @@ def feature_recipient_shoutout if registrant.shoutout_text.blank? && (bio = shoutout_bio_from_profile(registrant)) registrant.update!(shoutout_text: bio) end - redirect_to edit_event_registration_path(registration, return_to: "recipients", anchor: "shout-out"), + redirect_to edit_event_registration_path(registration, return_to: "recipients", scroll_to: "shout-out"), notice: "Featured on the recipients page — review their shout-out text below.", status: :see_other end diff --git a/app/frontend/javascript/controllers/reveal_section_controller.js b/app/frontend/javascript/controllers/reveal_section_controller.js index e8865a41cd..cabd13c9b4 100644 --- a/app/frontend/javascript/controllers/reveal_section_controller.js +++ b/app/frontend/javascript/controllers/reveal_section_controller.js @@ -1,8 +1,8 @@ import { Controller } from "@hotwired/stimulus" // Expands a collapsible section and scrolls it into view when the page loads -// with a matching URL hash — e.g. when linked from another page so the user -// lands on the section already open rather than collapsed or scrolled past. +// with a matching URL hash or scroll_to query parameter. The query parameter +// carries the target through Turbo form redirects, which drop URL fragments. // //
<%= locked_fieldset(locked) do %> -
+
diff --git a/spec/requests/events_spec.rb b/spec/requests/events_spec.rb index aa3cd68389..84b6e71806 100644 --- a/spec/requests/events_spec.rb +++ b/spec/requests/events_spec.rb @@ -3884,7 +3884,7 @@ def ce_chip_text expect(registration.reload.shoutout).to be(true) expect(response).to have_http_status(:see_other) expect(response).to redirect_to( - edit_event_registration_path(registration, return_to: "recipients", anchor: "shout-out") + edit_event_registration_path(registration, return_to: "recipients", scroll_to: "shout-out") ) end diff --git a/spec/system/events_recipient_shoutout_spec.rb b/spec/system/events_recipient_shoutout_spec.rb index f20dee1c46..ba1b756190 100644 --- a/spec/system/events_recipient_shoutout_spec.rb +++ b/spec/system/events_recipient_shoutout_spec.rb @@ -7,7 +7,14 @@ let(:scholarship_form) { create(:form, :scholarship) } let(:existing_recipient) { create(:person, first_name: "Alex", last_name: "Smith", shoutout_text: "Proud to serve.") } let!(:existing_registration) do - create(:event_registration, event: event, registrant: existing_recipient, status: "registered", scholarship_requested: true, shoutout: true) + create( + :event_registration, + event: event, + registrant: existing_recipient, + status: "registered", + scholarship_requested: true, + shoutout: true + ) end let(:applicant) { create(:person, first_name: "Tara", last_name: "Gallagher") } let!(:registration) do @@ -35,8 +42,9 @@ def select_recipient(registration_id) end expect(page).to have_current_path( - edit_event_registration_path(registration, return_to: "recipients", anchor: "shout-out") + edit_event_registration_path(registration, return_to: "recipients") ) + expect(page).to have_css("#shout-out") expect(page).to have_content("Featured on the recipients page — review their shout-out text below.") expect(registration.reload.shoutout).to be(true) end