-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #97853 Add Power of Attorney Request Models, Factories, and Specs #19919
Conversation
Generated by 🚫 Danger |
@ojbucao Let's use "Pull Request Stacks" so that these are easy to review. If you're building off of the work of a previous branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- we should question use of
validates
- i think we should consider subbing in DB defined cascading (unfortunately not exposed in
add_reference
but is exposed inadd_foreign_key
; sigh) and avoid doing meaningful work in model lifecycle callbacks (sorry, Rails made a mess in these areas) - please get in the habit of making PR stacks. these are hard to review otherwise. GH treats PR stacks conveniently, when stacked PR's base branch merges to main, dependent PR updates its base branch
power_of_attorney_form
validates :city_bidx, presence: true, length: { is: 44 } | ||
validates :state_bidx, presence: true, length: { is: 44 } | ||
validates :zipcode_bidx, presence: true, length: { is: 44 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why length?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the length of the cryptographic hash that results.
blind_index :zipcode | ||
|
||
# Validations | ||
validates :power_of_attorney_request_id, uniqueness: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See discussion on race conditions when checking uniqueness from ActiveRecord. Since this uniqueness constraint is not something a user can cause by their input, I don't think there is added benefit to implementing this with validations (which are convenient because they can collect issues for feedback for the user, but that's not our situation). Also, the PG adapter surfaces the RecordNotUnique
exception, so we'll know what's up.
validates :data_ciphertext, presence: true | ||
validates :city_bidx, presence: true, length: { is: 44 } | ||
validates :state_bidx, presence: true, length: { is: 44 } | ||
validates :zipcode_bidx, presence: true, length: { is: 44 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these are really controlled by user input and there's nowhere they ought to be shown back to the user. If these aren't valid it's a programming bug we caused and these have not null constraints in the DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll go ahead and remove them.
belongs_to :claimant, | ||
class_name: 'UserAccount' | ||
|
||
has_one :form, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
power_of_attorney_form
class PowerOfAttorneyForm < ApplicationRecord | ||
belongs_to :power_of_attorney_request, | ||
class_name: 'AccreditedRepresentativePortal::PowerOfAttorneyRequest', | ||
inverse_of: :form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
power_of_attorney_form
There is a meaningful semantic difference between poa form and poa request form. The latter doesn't make sense. A poa request will result in a poa form being made. It's marginal but I think leans this way a little.
belongs_to :creator, | ||
class_name: 'UserAccount' | ||
|
||
has_one :power_of_attorney_request_resolution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
has_one :power_of_attorney_request_resolution, | ||
as: :resolving, | ||
inverse_of: :resolving, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't look close but does inverse_of work in the polymorphic case? i'll look closer upon refinement of this PR if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right. my bad. removing it.
class PowerOfAttorneyRequestExpiration < ApplicationRecord | ||
has_one :power_of_attorney_request_resolution, | ||
as: :resolving, | ||
inverse_of: :resolving, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't look close but does inverse_of work in the polymorphic case? i'll look closer upon refinement of this PR if necessary.
# Validations | ||
validates :id, presence: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validates :id, presence: true
is something i've never seen before. I think it shouldn't be there.
...e_portal/app/models/accredited_representative_portal/power_of_attorney_request_resolution.rb
Show resolved
Hide resolved
@ojbucao I didn't review the fixtures and model specs really yet. |
3448bd9
to
1c3df00
Compare
1c3df00
to
6024452
Compare
7ec1183
to
af04c9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small changes, then this is ready to go:
- resolving not optional
- if there were issues here, maybe this way of creating both objects simultaneously is what we should have?
- i don't think we need any of the
validates
- don't need
dependent: :destroy
, we can do cascading deletes in the db
but let me know if you think i'm mistaken somewhere
'AccreditedRepresentativePortal::PowerOfAttorneyRequestDecision' | ||
].freeze | ||
|
||
delegated_type :resolving, types: RESOLVING_TYPES, dependent: :destroy, optional: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a follow up commit we can implement all the foreign key cascades and in this case maybe a trigger. let's remove AR's handling of this with dependent
has_one( | ||
:power_of_attorney_request_resolution, | ||
as: :resolving, | ||
touch: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looked up the touch
option and it's for updated timestamps which the sub types don't have so we can remove this
# Validations | ||
validates :resolving_type, presence: true, inclusion: { in: RESOLVING_TYPES, allow_nil: true } | ||
validates :resolving_id, presence: true, if: -> { resolving_type.present? } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't need this since association isn't optional
3252ccf
to
3815598
Compare
…POA requests - Override `table_name_prefix` to 'ar_' for models in the Accredited Representative Portal - Add `activerecord` as a development dependency to fix spec issues This ensures Power of Attorney request models in the engine use the correct table prefix and that all specs pass successfully.
3815598
to
f56149d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…cs (#19919) * (feat) Add PowerOfAttorneyRequest model, factory, and specs * (feat) Add PowerOfAttorneyRequestDecision model, factory, and specs * (feat) Add PowerOfAttorneyRequestExpiration model, factory, and specs * (feat) Add PowerOfAttorneyRequestResolution model, factory, and specs * (feat) Add PowerOfAttorneyForm model, factory, and specs * (fix) Rename directory due to misspelling * (fix) Add table name prefix override and ActiveRecord dependency for POA requests - (feat) Override `table_name_prefix` to 'ar_' for models in the Accredited Representative Portal - (feat) Add `activerecord` as a development dependency to fix spec issues This ensures Power of Attorney request models in the engine use the correct table prefix and that all specs pass successfully. * (fix) Apply requested PR changes; all specs passing
This PR introduces the core components for the Power of Attorney Request feature, ensuring a complete and testable implementation. Each model is accompanied by its corresponding factory for test data generation and RSpec tests for verification.
• PowerOfAttorneyRequest
• PowerOfAttorneyForm
• PowerOfAttorneyRequestDecision
• PowerOfAttorneyRequestExpiration
• PowerOfAttorneyRequestResolution
• Added factories for generating test data for the above models.
• Added unit tests to validate model behaviors and associations.