From 84d53b8bb5f0907316788ac982455a20967f31f2 Mon Sep 17 00:00:00 2001 From: maebeale Date: Mon, 29 Jun 2026 07:47:34 -0400 Subject: [PATCH] Org "Pending" badge: suppress once linked, surface on the link editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The roster's "Pending" org chip now shows only while a registrant has no linked organization — once an admin links any org they've made the call, so a non-matching submitted name no longer reads as pending. For continuity, the link-organization editor now shows the same amber "Pending" badge next to the submitted org name while nothing is linked, so it's clear why the registrant was flagged when you open it. Co-Authored-By: Claude Opus 4.8 --- .../link_organization.html.erb | 2 +- app/views/events/_registrants_results.html.erb | 8 ++++---- spec/requests/event_registrations_spec.rb | 18 ++++++++++++++++++ spec/requests/events_spec.rb | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/views/event_registrations/link_organization.html.erb b/app/views/event_registrations/link_organization.html.erb index 53520ca02c..eabdecd84a 100644 --- a/app/views/event_registrations/link_organization.html.erb +++ b/app/views/event_registrations/link_organization.html.erb @@ -54,7 +54,7 @@ <% end %>
-

Organization: <%= entry[:org_name].presence || "—" %><% if entry[:organization]&.city_state.present? %> · <%= entry[:organization].city_state %><% end %>

+

Organization: <%= entry[:org_name].presence || "—" %><% if entry[:organization]&.city_state.present? %> · <%= entry[:organization].city_state %><% end %><%# Mirror the roster's amber "Pending" chip so it's clear why this registrant was flagged — shown only while nothing is linked. %><% if entry[:org_name].present? && @linked_organizations.none? %> Pending<% end %>

Position / title: <%= entry[:position].presence || "—" %>

diff --git a/app/views/events/_registrants_results.html.erb b/app/views/events/_registrants_results.html.erb index 00cb99afb8..5e458c9695 100644 --- a/app/views/events/_registrants_results.html.erb +++ b/app/views/events/_registrants_results.html.erb @@ -118,10 +118,10 @@ <% linked_orgs = registration.organizations %> <% submitted_org_name = submitted_org_names[registration.registrant_id].to_s.strip %> - <% linked_org_names = linked_orgs.map { |org| org.name.to_s.strip.downcase } %> - <%# A submitted name not represented among the linked orgs still needs admin - attention; a name matching a linked org is already resolved. %> - <% needs_linking = submitted_org_name.present? && linked_org_names.exclude?(submitted_org_name.downcase) %> + <%# A submitted org name needs admin attention only while nothing is linked + yet; once an admin links any org they've made the call, so a non-matching + submitted name is no longer treated as pending. %> + <% needs_linking = submitted_org_name.present? && linked_orgs.none? %> <% editor_path = link_organization_event_registration_path(registration, return_to: "registrants") %> <% pill_classes = "inline-flex items-center gap-1.5 rounded-full text-xs font-medium border px-3 py-0.5 transition hover:opacity-80 hover:shadow-sm" %>
diff --git a/spec/requests/event_registrations_spec.rb b/spec/requests/event_registrations_spec.rb index 5658219233..f1d7361466 100644 --- a/spec/requests/event_registrations_spec.rb +++ b/spec/requests/event_registrations_spec.rb @@ -574,6 +574,24 @@ def details_open?(body, heading) expect(response.body).not_to include("No registration form was submitted") end + it "shows a 'Pending' badge next to the submitted org when nothing is linked" do + existing_registration.event_registration_organizations.destroy_all + submit_form(org_name: "Riverside Healing Arts Collective") + + get link_organization_event_registration_path(existing_registration) + + expect(response.body).to include("Riverside Healing Arts Collective") + expect(response.body).to include(">Pending<") + end + + it "does not show the 'Pending' badge once an organization is linked" do + submit_form(org_name: "Riverside Healing Arts Collective") + + get link_organization_event_registration_path(existing_registration) + + expect(response.body).not_to include(">Pending<") + end + it "shows 'Create org & link' when the submitted org has no existing match" do submit_form(org_name: "Brand New Unlisted Org") diff --git a/spec/requests/events_spec.rb b/spec/requests/events_spec.rb index 1420b0dffb..cf0f8e177d 100644 --- a/spec/requests/events_spec.rb +++ b/spec/requests/events_spec.rb @@ -591,14 +591,14 @@ def submit_agency_name(name) expect(response.body).not_to include(">Pending<") end - it "shows the linked org AND a 'Pending' chip when the submitted name is not among the linked orgs" do + it "does not show a 'Pending' chip when an org is linked, even if the submitted name differs" do create(:event_registration_organization, event_registration: registration, organization: organization) submit_agency_name("A Different Unlisted Agency") get registrants_event_path(event) expect(response.body).to include(organization.name) - expect(response.body).to include(">Pending<") + expect(response.body).not_to include(">Pending<") end it "does not show 'Pending' when the submitted name matches a linked org" do