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

[Disability Benefits Team 1 DBEX-TREX] Force IPF submissions without startedFormVersion to get set as '2019' #19989

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@ def data_and_metadata_with_updated_rated_disabilities

# for Toxic Exposure 1.1 - add indicator to In Progress Forms
# moving forward, we don't want to change the version if it is already there
if Flipper.enabled?(:disability_526_toxic_exposure_ipf,
@current_user) && parsed_form_data['startedFormVersion'].blank?
parsed_form_data['startedFormVersion'] = '2019'
end

parsed_form_data = set_started_form_version(parsed_form_data)
{
formData: parsed_form_data,
metadata:
}
end

def set_started_form_version(data)
if Flipper.enabled?(:disability_526_toxic_exposure_ipf,
@current_user) && data['startedFormVersion'].blank?
log_started_form_version(data, 'existing IPF missing startedFormVersion')
data['startedFormVersion'] = '2019'
end
data
end

def rated_disabilities_evss
@rated_disabilities_evss ||= FormProfiles::VA526ez.for(form_id:, user: @current_user)
.initialize_rated_disabilities_information
Expand Down
5 changes: 3 additions & 2 deletions app/models/form_profiles/va_526ez.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ def prefill_base_class_methods

def initialize_form526_prefill
VA526ez::Form526Prefill.new(
# any form that has a startedFormVersion (whether it is '2019' or '2022') will go through the Toxic Exposure flow
# any new form should have a '2022' startedFormVersion in order to go through the Toxic Exposure flow
# but we never want this field to be nil in order to catch any
# '2022' means the Toxic Exposure 1.0 flag.
started_form_version: Flipper.enabled?(:disability_526_toxic_exposure, user) ? '2022' : nil,
started_form_version: Flipper.enabled?(:disability_526_toxic_exposure, user) ? '2022' : '2019',
sync_modern_0781_flow: Flipper.enabled?(:disability_compensation_sync_modern_0781_flow, user)
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ def translate
output_form['overflowText'] = overflow_text
output_form['bddQualified'] = bdd_qualified?
output_form['claimSubmissionSource'] = 'VA.gov'
# any form that has a startedFormVersion (whether it is '2019' or '2022')
# will go through the Toxic Exposure flow
output_form['startedFormVersion'] = input_form['startedFormVersion'] || nil
output_form.compact!

output_form.update(translate_banking_info)
output_form.update(translate_service_pay)
output_form.update(translate_service_info)
Expand All @@ -72,7 +68,8 @@ def translate
output_form.update(translate_disabilities)
# any form that has a startedFormVersion (whether it is '2019' or '2022')
# will go through the Toxic Exposure flow
output_form.update(add_toxic_exposure) if output_form['startedFormVersion']
output_form.update(translate_started_form_version)
output_form.update(add_toxic_exposure)

@translated_form
end
Expand Down Expand Up @@ -226,6 +223,13 @@ def direct_deposit(type, account_number, routing_number, bank_name)
}
end

###
# Started Form Version
###
def translate_started_form_version
{ 'startedFormVersion' => input_form['startedFormVersion'] || '2019' }
end

###
# Service pay
###
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,54 @@
end
end

describe '#translateStartedFormVersion' do
context 'no startedFormVersion on input form' do
let(:form_content) do
{
'form526' => {}
}
end

it 'adds in startedFormVersion when it was missing' do
expect(subject.send(:translate_started_form_version)).to eq({
'startedFormVersion' => '2019'
})
end
end

context 'startedFormVersion is 2022' do
let(:form_content) do
{
'form526' => {
'startedFormVersion' => '2022'
}
}
end

it 'adds in startedFormVersion when it was missing' do
expect(subject.send(:translate_started_form_version)).to eq({
'startedFormVersion' => '2022'
})
end
end

context 'startedFormVersion is 2019' do
let(:form_content) do
{
'form526' => {
'startedFormVersion' => '2019'
}
}
end

it 'fills in 2019 startedFormVersion' do
expect(subject.send(:translate_started_form_version)).to eq({
'startedFormVersion' => '2019'
})
end
end
end

describe '#add_toxic_exposure' do
let(:form_content) do
{
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/v0/disability_compensation_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_error(cassette_path, status, headers)
expect(response).to match_response_schema('submit_disability_form')
expect(Form526Submission.count).to eq(1)
form = Form526Submission.last.form
expect(form.dig('form526', 'form526', 'startedFormVersion')).to eq(nil)
expect(form.dig('form526', 'form526', 'startedFormVersion')).to eq('2019')
end
end

Expand Down
Loading