From 1aaad3a10d954f7d95a4b3142201899973f20fe6 Mon Sep 17 00:00:00 2001 From: Evan Smith Date: Mon, 8 Apr 2024 16:41:42 -0400 Subject: [PATCH] assign state to no if national is yes. alter tests to handle this scenario --- lib/pdf_fill/forms/va21p530v2.rb | 6 ++++++ .../pdf_fill/21P-530V2/kitchen_sink.json | 2 -- .../pdf_fill/21P-530V2/merge_fields.json | 9 +++------ spec/lib/pdf_fill/forms/va21p530v2_spec.rb | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/pdf_fill/forms/va21p530v2.rb b/lib/pdf_fill/forms/va21p530v2.rb index f2b8c6124d7..a105a1b04d9 100644 --- a/lib/pdf_fill/forms/va21p530v2.rb +++ b/lib/pdf_fill/forms/va21p530v2.rb @@ -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']) @@ -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') diff --git a/spec/fixtures/pdf_fill/21P-530V2/kitchen_sink.json b/spec/fixtures/pdf_fill/21P-530V2/kitchen_sink.json index f4bc77bd629..6662d6946c4 100644 --- a/spec/fixtures/pdf_fill/21P-530V2/kitchen_sink.json +++ b/spec/fixtures/pdf_fill/21P-530V2/kitchen_sink.json @@ -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"}, diff --git a/spec/fixtures/pdf_fill/21P-530V2/merge_fields.json b/spec/fixtures/pdf_fill/21P-530V2/merge_fields.json index 108b49025f0..951fcd309ae 100644 --- a/spec/fixtures/pdf_fill/21P-530V2/merge_fields.json +++ b/spec/fixtures/pdf_fill/21P-530V2/merge_fields.json @@ -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"}, @@ -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", @@ -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", diff --git a/spec/lib/pdf_fill/forms/va21p530v2_spec.rb b/spec/lib/pdf_fill/forms/va21p530v2_spec.rb index 4a93060e073..d1c2f117cda 100644 --- a/spec/lib/pdf_fill/forms/va21p530v2_spec.rb +++ b/spec/lib/pdf_fill/forms/va21p530v2_spec.rb @@ -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(