Skip to content
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

API-41395-rep-validation-suffix-II #19071

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

stiehlrod
Copy link
Contributor

@stiehlrod stiehlrod commented Oct 24, 2024

Summary

  • Adds attr_acessor to claims_user and user_identity.
  • Passes suffix to all_for_user in poa_verification and target_veteran.
  • Removes get_suffixes method in representative, and adds suffix lookup using the identity suffix.

Related issue(s)

Testing done

  • New code is covered by unit tests
  • This touches all of our endpoints
  • I have tested v1 claims, ews, ITF v1 & v2, 526 v1 & v2

What areas of the site does it impact?

modified:   modules/claims_api/app/controllers/concerns/claims_api/claims_user.rb
modified:   modules/claims_api/app/controllers/concerns/claims_api/poa_verification.rb
modified:   modules/claims_api/app/controllers/concerns/claims_api/target_veteran.rb
modified:   modules/claims_api/app/controllers/concerns/claims_api/token_validation.rb
modified:   modules/claims_api/app/controllers/concerns/claims_api/user_identifier.rb
modified:   modules/veteran/app/models/veteran/service/representative.rb
modified:   modules/veteran/spec/models/veteran/service/representative_spec.rb

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Requested Feedback

Ideas on how to better test the suffix lookup.

…all_for_user in poa_verification and target_veteran. Removes get_suffixes method in representative, and adds suffix lookup using the identity suffix.
@stiehlrod stiehlrod self-assigned this Oct 24, 2024
@stiehlrod stiehlrod marked this pull request as ready for review October 24, 2024 18:59
@stiehlrod stiehlrod requested review from a team as code owners October 24, 2024 18:59
@va-vfs-bot va-vfs-bot temporarily deployed to API-41395-rep-validation-suffix-II/main/main October 24, 2024 19:01 Inactive
@stiehlrod stiehlrod changed the title Adds attr_acessor to claims_user and user_identity. Passes suffix to … API-41395-rep-validation-suffix-II Oct 24, 2024
Copy link
Contributor

@tycol7 tycol7 left a comment

Choose a reason for hiding this comment

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

looking good, some questions below.

Copy link
Contributor

@tycol7 tycol7 left a comment

Choose a reason for hiding this comment

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

I think we will return nil if we find a representative with a suffix in their last name.

Comment on lines +116 to +124
representatives = if suffix.present?
last_and_suffix = "#{last_name} #{suffix.downcase}"

representatives = where('lower(first_name) = ? AND lower(last_name) = ?', first_name&.downcase,
last_name&.downcase)
where('lower(first_name) = ? AND lower(last_name) = ?', first_name&.downcase,
last_and_suffix&.downcase)
end
if representatives.blank?
where('lower(first_name) = ? AND lower(last_name) = ?', first_name&.downcase,
last_name&.downcase)
Copy link
Contributor

@tycol7 tycol7 Oct 25, 2024

Choose a reason for hiding this comment

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

We aren't returning anything if we find representatives with a suffix (i.e., the function will return nil if representatives is not blank). Should we add a return statement either after line 121 or 124 5?

Comment on lines 73 to 80
it 'can find a user with a suffix' do
expect(Veteran::Service::Representative.all_for_user(
first_name: identity.first_name,
last_name: "#{identity.last_name} III",
last_name: identity.last_name,
suffix: 'Jr',
poa_code: 'A1Q'
).first.poa_codes).to include('A1Q')
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we create a test user with a suffix in their last name, so we can exercise the case where we find a user by their suffix? This test will strip the suffix (Jr) because there is no lincoln jr in the database, which conceals the error in our return logic.

Comment on lines 83 to +84
last_name: @current_user.last_name,
middle_initial:)
middle_initial:, suffix:)
Copy link
Contributor

Choose a reason for hiding this comment

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

we could keep the logic here and not modify the all_for_user method at all. we can just do the existing lookup

first_name: @current_user.first_name,
last_name: @current_user.last_name

and if we don't find anything we can do something like

last_with_suffix = [@current_user.last_name, @current_user.suffix].compact_blank.join(' ')

first_name: @current_user.first_name,
last_name: last_with_suffix

Copy link
Contributor

Choose a reason for hiding this comment

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

actually seeing undefined local variable or method 'suffix' in local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants