Skip to content

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

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

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

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 PR, suggested 👤 review level: 📖 Read — light-logic: small specify-option change plus a guarded org write, no migration

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

  • When a registrant picks "Other" for Organization Type, the free text they type was previously lost — it stored the literal option label and never reached the organization.
  • Now "Other" behaves like every other specify option (reveals a "please specify" box, stores "Other: <text>"), and the answer is mirrored onto the linked organization’s agency_type / 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 (no extra wiring).
  • organizations/_form.html.erb: org edit select now offers "Other" so the synced value renders selected.
  • public_registration.rb: new update_agency_type splits the answer — option label → agency_type, stripped free text → agency_type_other (cleared for non-Other choices). Latest registration wins; AhoyTrackable records before/after on each update, so prior values are auditable.

Anything else to add?

  • No data migration (per request): the new behavior applies to forms built after this change. Existing forms keep the old "Other (please specify below)" option until re-seeded.
  • Org sync only runs when a registration links an existing org by name (registration never creates orgs — unchanged).
  • Tests: 6 specs added/updated; suite green.

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>
# 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.

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.

1 participant