Skip to content

Commit

Permalink
77562 & 78993 [10-10EZR]: Add backend log to help diagnose rare DOB i…
Browse files Browse the repository at this point in the history
…ssue (#16124)

* Added PersonalInformationLog for DOB

* Fixed linting issues

* Cloned just the 'veteranDateOfBirth' field instead of the whole form
  • Loading branch information
JoshingYou1 authored Mar 29, 2024
1 parent e35b7e8 commit 1bfc2aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/form1010_ezr/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def submit_sync(parsed_form)

# @param [HashWithIndifferentAccess] parsed_form JSON form data
def submit_form(parsed_form)
# Log the 'veteranDateOfBirth' to ensure the frontend validation is working as intended
# REMOVE THE FOLLOWING TWO LINES OF CODE ONCE THE DOB ISSUE HAS BEEN DIAGNOSED - 3/27/24
@unprocessed_user_dob = parsed_form['veteranDateOfBirth'].clone
parsed_form = configure_and_validate_form(parsed_form)

if Flipper.enabled?(:ezr_async, @user)
Expand Down Expand Up @@ -92,6 +95,14 @@ def validate_form(parsed_form)
validation_errors = JSON::Validator.fully_validate(schema, parsed_form)

if validation_errors.present?
# REMOVE THE FOLLOWING SIX LINES OF CODE ONCE THE DOB ISSUE HAS BEEN DIAGNOSED - 3/27/24
if validation_errors.find { |error| error.include?('veteranDateOfBirth') }.present?
PersonalInformationLog.create!(
data: @unprocessed_user_dob,
error_class: "Form1010Ezr 'veteranDateOfBirth' schema failure"
)
end

log_validation_errors(parsed_form)

Rails.logger.error('10-10EZR form validation failed. Form does not match schema.')
Expand Down
18 changes: 18 additions & 0 deletions spec/lib/form1010_ezr/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,24 @@ def submit_form(form)
submit_form(form)
end.to raise_error(StandardError)
end

# REMOVE THIS TEST ONCE THE DOB ISSUE HAS BEEN DIAGNOSED - 3/27/24
context "when the error pertains to the Veteran's DOB" do
before do
allow(JSON::Validator).to receive(:fully_validate).and_return(['veteranDateOfBirth error'])
end

it 'adds to the PersonalInformationLog and saves the unprocessed DOB' do
expect { submit_form(form) }.to raise_error do |e|
personal_information_log =
PersonalInformationLog.find_by(error_class: "Form1010Ezr 'veteranDateOfBirth' schema failure")

expect(personal_information_log.present?).to eq(true)
expect(personal_information_log.data).to eq(form['veteranDateOfBirth'])
expect(e).to be_a(Common::Exceptions::SchemaValidationErrors)
end
end
end
end

context 'any other error' do
Expand Down

0 comments on commit 1bfc2aa

Please sign in to comment.