Skip to content

Commit

Permalink
assign state to no if national is yes. alter tests to handle this sce…
Browse files Browse the repository at this point in the history
…nario
  • Loading branch information
evansmith committed Apr 8, 2024
1 parent 57d14ca commit 1aaad3a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
6 changes: 6 additions & 0 deletions lib/pdf_fill/forms/va21p530v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,11 @@ def combine_previous_names_and_service(previous_names)
end.join('; ')
end

def set_state_to_no_if_national
national = @form_data['nationalOrFederal']
@form_data['cemetaryLocationQuestion'] = 'none' if national
end

# rubocop:disable Metrics/MethodLength
def merge_fields(_options = {})
expand_signature(@form_data['claimantFullName'])
Expand Down Expand Up @@ -709,6 +714,7 @@ def merge_fields(_options = {})
@form_data['noProcessOption'] = process_option ? nil : 'On'

expand_confirmation_question
set_state_to_no_if_national
expand_location_question

split_phone(@form_data, 'claimantPhone')
Expand Down
2 changes: 0 additions & 2 deletions spec/fixtures/pdf_fill/21P-530V2/kitchen_sink.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"plotExpenseResponsibility":true,
"govtContributions":true,
"amountGovtContribution":"50000",
"cemeteryLocation":{"name":"state cemetery", "zip":"04102"},
"cemetaryLocationQuestion":"cemetery",
"nationalOrFederal":true,
"name":"name of cemetery",
"finalRestingPlace":{"location":"other", "other":"other"},
Expand Down
9 changes: 3 additions & 6 deletions spec/fixtures/pdf_fill/21P-530V2/merge_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"plotExpenseResponsibility":true,
"govtContributions":true,
"amountGovtContribution":"50000",
"cemeteryLocation":{"name":"state cemetery", "zip":"04102"},
"cemetaryLocationQuestion":"cemetery",
"nationalOrFederal":true,
"name":"name of cemetery",
"finalRestingPlace":{"location":{"cemetery":"Off", "privateResidence":"Off", "mausoleum":"Off", "other":"On"}, "other":"other"},
Expand Down Expand Up @@ -76,8 +74,6 @@
"signatureDate":"2024-03-21",
"veteranSocialSecurityNumber2":{"first":"987", "second":"65", "third":"4322"},
"veteranSocialSecurityNumber3":{"first":"987", "second":"65", "third":"4322"},
"stateCemeteryOrTribalTrustName":"state cemetery",
"stateCemeteryOrTribalTrustZip":"04102",
"hasBurialExpenseResponsibility":"On",
"noBurialExpenseResponsibility":null,
"hasPlotExpenseResponsibility":"On",
Expand All @@ -86,9 +82,10 @@
"noProcessOption":"On",
"hasConfirmation":"YES",
"noConfirmation":null,
"cemetaryLocationQuestionCemetery":"On",
"cemetaryLocationQuestion":"none",
"cemetaryLocationQuestionCemetery":"Off",
"cemetaryLocationQuestionTribal":"Off",
"cemetaryLocationQuestionNone":"Off",
"cemetaryLocationQuestionNone":"On",
"hasNationalOrFederal":"YES",
"noNationalOrFederal":null,
"hasGovtContributions":"YES",
Expand Down
19 changes: 19 additions & 0 deletions spec/lib/pdf_fill/forms/va21p530v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,25 @@ def class_form_data
end
end

describe 'set_state_to_no_if_national' do
subject do
new_form_class.set_state_to_no_if_national
end

context 'with a regular location of death' do
let(:form_data) do
{
'nationalOrFederal' => true
}
end

it 'returns the directly mapped location' do
subject
expect(class_form_data['cemetaryLocationQuestion']).to eq('none')
end
end
end

describe '#merge_fields' do
it 'merges the right fields', run_at: '2024-03-21 00:00:00 EDT' do
expect(described_class.new(get_fixture('pdf_fill/21P-530V2/kitchen_sink')).merge_fields.to_json).to eq(
Expand Down

0 comments on commit 1aaad3a

Please sign in to comment.