Skip to content

Sync registration "Other" organization type onto the linked org#1875

Open
maebeale wants to merge 1 commit into
mainfrom
maebeale/sector-other-storage
Open

Sync registration "Other" organization type onto the linked org#1875
maebeale wants to merge 1 commit into
mainfrom
maebeale/sector-other-storage

Conversation

@maebeale

@maebeale maebeale commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

🤖 PR, suggested 👤 review level: 📖 Read — light-logic: refines the existing org-profile sync plus a small form-option change

What is the goal of this PR and why is this important?

  • When a registrant picks "Other" for Organization Type, the free text they typed was being dropped — the org’s agency_type_other was only ever set from the admin edit form.
  • Now "Other" behaves like every other specify option (reveals a "please specify" box, stores "Other: <text>"), and the answer is split onto the linked organization: option label → agency_type, stripped free text → agency_type_other.

How did you approach the change?

  • form_builder_service.rb: the agency-type option is now bare "Other", which auto-qualifies as a generic specify option (reveals the box, folds to "Other: <text>").
  • organizations/_form.html.erb: org edit select now offers "Other" so the synced value renders selected.
  • public_registration.rb: sync_organization_profile already wrote agency_type (latest-wins) after the recent org-sync work on main; this replaces the plain write with sync_agency_type, which splits the label from the free text and fills/clears agency_type_other. Same latest-wins / never-clobber-on-blank contract as apply_value; AhoyTrackable records before/after.

Anything else to add?

  • No data migration: new behavior applies to forms built after this change; existing forms keep the old "Other (please specify below)" option until re-seeded.
  • Rebased on main (which introduced sync_organization_profile); folded the "Other" split into that method rather than adding a parallel path.
  • Tests: 6 specs added; full service + form-builder suites green (118 examples).

# wins; AhoyTrackable records the before/after on the update.
def update_agency_type(organization)
raw = field_value("agency_type").to_s.strip
label, _separator, specified = raw.partition(":")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 From Claude: partition(":") is safe here because none of the agency-type option labels contain a colon, so the split always yields the option label and (for "Other") the typed free text. agency_type_other is cleared for non-"Other" choices to avoid leaving stale text behind.

Why: a registrant who picked "Other" for organization type had nowhere to
record what that "other" was, and the org's agency_type_other column was only
ever set from the admin edit form. Make the registration "Other" choice behave
like every other specify option (reveals a box, stores "Other: <text>") and
mirror the answer onto the linked organization so the free text isn't lost.

Latest registration wins; AhoyTrackable records the before/after on each update.
No data migration — new behavior applies to forms built after this change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maebeale maebeale changed the title WAIT: Sync registration "Other" organization type onto the linked org Sync registration "Other" organization type onto the linked org Jul 4, 2026
Copilot AI review requested due to automatic review settings July 4, 2026 14:53
@maebeale maebeale force-pushed the maebeale/sector-other-storage branch from 0a523db to 791ff63 Compare July 4, 2026 14:53
# agency_type_other, which is cleared for the non-"Other" classifications so
# no stale free text lingers. Follows the same latest-wins / never-clobber-on-
# blank contract as apply_value.
def sync_agency_type(organization)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 From Claude: Folded into sync_organization_profile on rebase: partition(":") splits the option label from the "Other" free text (safe — no agency-type label contains a colon). agency_type_other is cleared for the non-"Other" classifications so no stale text lingers.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates public event registration and the organization edit UI so that selecting “Other” for Organization Type behaves like a standard “specify” option and syncs cleanly onto the linked Organization (agency_type + agency_type_other), instead of dropping or mis-storing the free-text detail.

Changes:

  • Change the registration form’s agency type option to bare "Other" so it qualifies as a specify option (stored as "Other: <text>").
  • Update org admin edit select options to include "Other" so synced values render correctly.
  • Replace the org sync write with sync_agency_type, splitting "Other: <text>" into agency_type="Other" and agency_type_other="<text>", with added specs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
app/services/event_registration_services/public_registration.rb Introduces sync_agency_type to parse/sync "Other: <text>" into structured org fields.
app/services/form_builder_service.rb Updates the “Organization Type” options so "Other" triggers specify-option behavior.
app/views/organizations/_form.html.erb Updates the admin org form select options to match the new "Other" value.
spec/services/event_registration_services/public_registration_spec.rb Adds coverage for syncing agency_type/agency_type_other across “Other” and non-“Other” cases.
spec/services/form_builder_service_spec.rb Updates expected agency type options and asserts "Other" is treated as a specify option.
Comments suppressed due to low confidence (1)

app/views/organizations/_form.html.erb:120

  • blocker: If an Organization already has a legacy agency_type value (e.g. the previous "Other (please specify below)" string), it won’t match any option in this select. In that case the browser will default to the first option and saving the form can silently change agency_type to "501c3/nonprofit". Consider normalizing any stored "Other…" value to "Other" for the selected/value so existing records don’t get clobbered on edit.
                    "Other"
                  ],
                  selected: f.object.agency_type,
                  input_html: {
                    value: f.object.agency_type,

Comment on lines +200 to +206
raw = field_value("agency_type")
return if raw.blank?

label, _separator, specified = raw.strip.partition(":")
label = label.strip
other_text = FormField.other_option?(label) ? specified.strip.presence : nil
organization.update!(agency_type: label, agency_type_other: other_text)
@maebeale maebeale marked this pull request as ready for review July 4, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants