human-essentials icon indicating copy to clipboard operation
human-essentials copied to clipboard

Change agency_type to a Rails enum

Open dorner opened this issue 3 months ago • 8 comments

Summary

There are a number of tests that check PartnerProfile#agency_type against a string "Other". Some other tests check the value in an array instead:

Partner::AGENCY_TYPES['OTHER']

This seems to be hiding a hidden issue, which is that this field really should be an enum. We don't need to go all the way to defining a Postgres enum; we can just turn the field into a Rails enum as documented here.

Things to consider

A bonus to this would be moving the AGENCY_TYPES map from the Partner class to the PartnerProfile class, as that's where it's actually used.

Criteria for Completion

  • [] Agency type is a Rails enum.
  • Specs are updated to query e.g. profile.other? instead of checking against any specific string value.
  • All other functionality still works as expected.

dorner avatar Mar 31 '24 14:03 dorner