Skip to content

Commit

Permalink
10-10EZR: Financial Info not showing up in VES (#14612)
Browse files Browse the repository at this point in the history
* add fin flag

* use merge!

* new vcr

* typo

* typo

* update authorized submit

* record vcr

* fix auth submit with province vcr

* fix mexican province spec

* lint

* fix req spec

* fix ezrs req spec

* add fin flag only if veteran gross income present

* add fin flag spec
  • Loading branch information
lihanli authored Nov 27, 2023
1 parent f5d97a6 commit 7e15a8a
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 72 deletions.
11 changes: 10 additions & 1 deletion lib/form1010_ezr/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize(user)
# @param [HashWithIndifferentAccess] parsed_form JSON form data
def submit_form(parsed_form)
begin
configure_and_validate_form(parsed_form)
parsed_form = configure_and_validate_form(parsed_form)

formatted = HCA::EnrollmentSystem.veteran_to_save_submit_form(parsed_form, @user)
content = Gyoku.xml(formatted)
Expand Down Expand Up @@ -81,6 +81,15 @@ def configure_and_validate_form(parsed_form)
validate_form(parsed_form)
# Due to overriding the JSON form schema, we need to do so after the form has been validated
override_parsed_form(parsed_form)
add_financial_flag(parsed_form)
end

def add_financial_flag(parsed_form)
if parsed_form['veteranGrossIncome'].present?
parsed_form.merge('discloseFinancialInformation' => true)
else
parsed_form
end
end

def log_validation_errors(parsed_form)
Expand Down
35 changes: 29 additions & 6 deletions spec/lib/form1010_ezr/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

let(:form) { get_fixture('form1010_ezr/valid_form') }
let(:current_user) { build(:evss_user, :loa3, icn: '1013032368V065534') }
let(:service) { described_class.new(current_user) }

def allow_logger_to_receive_error
allow(Rails.logger).to receive(:error)
Expand All @@ -21,10 +22,32 @@ def submit_form(form)
described_class.new(current_user).submit_form(form)
end

describe '#add_financial_flag' do
context 'when the form has veteran gross income' do
let(:parsed_form) do
{
'veteranGrossIncome' => 100
}
end

it 'adds the financial_flag' do
expect(service.send(:add_financial_flag, parsed_form)).to eq(
parsed_form.merge('discloseFinancialInformation' => true)
)
end
end

context 'when the form doesnt have veteran gross income' do
it 'doesnt add the financial_flag' do
expect(service.send(:add_financial_flag, {})).to eq({})
end
end
end

describe '#submit_form' do
context 'when successful' do
it "returns an object that includes 'success', 'formSubmissionId', and 'timestamp'",
run_at: 'Mon, 23 Oct 2023 23:09:43 GMT' do
run_at: 'Tue, 21 Nov 2023 20:42:44 GMT' do
VCR.use_cassette(
'form1010_ezr/authorized_submit',
{ match_requests_on: %i[method uri body], erb: true }
Expand All @@ -40,8 +63,8 @@ def submit_form(form)
expect(submission_response).to eq(
{
success: true,
formSubmissionId: 432_236_891,
timestamp: '2023-10-23T18:12:24.628-05:00'
formSubmissionId: 432_775_981,
timestamp: '2023-11-21T14:42:44.858-06:00'
}
)
end
Expand All @@ -51,7 +74,7 @@ def submit_form(form)
let(:form) { get_fixture('form1010_ezr/valid_form_with_mexican_province') }

it "overrides the original province 'state' with the correct province initial and renders a " \
'successful response', run_at: 'Mon, 23 Oct 2023 23:42:13 GMT' do
'successful response', run_at: 'Tue, 21 Nov 2023 22:29:52 GMT' do
VCR.use_cassette(
'form1010_ezr/authorized_submit_with_mexican_province',
{ match_requests_on: %i[method uri body], erb: true }
Expand All @@ -62,8 +85,8 @@ def submit_form(form)
expect(submit_form(form)).to eq(
{
success: true,
formSubmissionId: 432_236_923,
timestamp: '2023-10-23T18:42:52.975-05:00'
formSubmissionId: 432_777_930,
timestamp: '2023-11-21T16:29:52.432-06:00'
}
)
end
Expand Down
12 changes: 6 additions & 6 deletions spec/requests/form1010_ezrs_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
end
let(:body) do
{
'formSubmissionId' => 432_236_891,
'timestamp' => '2023-10-23T18:12:24.628-05:00',
'formSubmissionId' => 432_775_981,
'timestamp' => '2023-11-21T14:42:44.858-06:00',
'success' => true
}
end

it 'renders a successful response and deletes the saved form', run_at: 'Mon, 23 Oct 2023 23:09:43 GMT' do
it 'renders a successful response and deletes the saved form', run_at: 'Tue, 21 Nov 2023 20:42:44 GMT' do
VCR.use_cassette(
'form1010_ezr/authorized_submit',
{ match_requests_on: %i[method uri body], erb: true }
Expand All @@ -74,14 +74,14 @@
end
let(:body) do
{
'formSubmissionId' => 432_236_923,
'timestamp' => '2023-10-23T18:42:52.975-05:00',
'formSubmissionId' => 432_777_930,
'timestamp' => '2023-11-21T16:29:52.432-06:00',
'success' => true
}
end

it "overrides the original province 'state' with the correct province initial and renders a " \
'successful response', run_at: 'Mon, 23 Oct 2023 23:42:13 GMT' do
'successful response', run_at: 'Tue, 21 Nov 2023 22:29:52 GMT' do
VCR.use_cassette(
'form1010_ezr/authorized_submit_with_mexican_province',
{ match_requests_on: %i[method uri body], erb: true }
Expand Down
Loading

0 comments on commit 7e15a8a

Please sign in to comment.