Api 55108 v2 val use claim date#27550
Conversation
There was a problem hiding this comment.
Pull request overview
Cleans up Claims API v2 526 validation logic by removing the locally-defined claim_date method and reusing the shared implementation from ClaimsApi::DisabilityCompensationValidationsHelper, aligning v2 behavior with other validations.
Changes:
- Include
ClaimsApi::DisabilityCompensationValidationsHelperin the v2 disability compensation validation concern and remove the duplicateclaim_datemethod. - Update v2 validation specs to expect
Date.current(matching the helper fallback) instead ofTime.zone.today.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| modules/claims_api/app/controllers/concerns/claims_api/v2/disability_compensation_validation.rb | Removes duplicate claim_date and includes shared validations helper. |
| modules/claims_api/spec/lib/claims_api/v2/disability_compensation_validation_spec.rb | Updates expectations to match shared helper fallback date behavior. |
| return if form_attributes.empty? | ||
|
|
||
| alt_rev_validate_claim_process_type_bdd if bdd_claim? | ||
| # ensure 'claimDate', if provided, is not in the future |
There was a problem hiding this comment.
noticed claimDate business logic was not being checked before we used it for validations. This probably could have waited until the claimDate was actually added to the schema, so open to revert but I don't think it hurts anything.
|
|
||
| private | ||
|
|
||
| def claim_date |
There was a problem hiding this comment.
This was a repeat of the helper file claim_date method
jeremyhunton-va
left a comment
There was a problem hiding this comment.
Code looks good to me! I'll pull this down after lunch and do a quick smoke test before I sign off.
# Conflicts: # modules/claims_api/app/controllers/concerns/claims_api/v2/disability_compensation_validation.rb
f1ec987
| it 'collects an error with the correct message' do | ||
| future_date = (Date.current + 1.day).iso8601 | ||
| test_526_validation_instance.form_attributes['claimDate'] = future_date | ||
| test_526_validation_instance.instance_variable_set(:@claim_date, nil) |
There was a problem hiding this comment.
The test manually resets @claim_date with instance_variable_set(:@claim_date, nil). This is fine for testing, but note that claim_date in the shared helper uses memoization (@claim_date = ...). If claim_date was previously called in the test setup with a non-future date, and @claim_date isn't reset, the validation would pass incorrectly. The test does reset it, so it works — but this is worth noting as a pattern that couples tests to internal implementation details.
Summary
V2 validation was largely updated in #27361, this PR is just clean up
time.date.now.disability_compensation_validations_helper.rbRelated issue(s)
API-55108

Testing done
What areas of the site does it impact?
Acceptance criteria