Skip to content

Commit

Permalink
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
Browse files Browse the repository at this point in the history
…ocalBGS
  • Loading branch information
mchristiansonVA authored Jan 7, 2025
2 parents 89f12a7 + 8f3b819 commit f2ef47c
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 17 deletions.
13 changes: 4 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ GEM
GEM
remote: https://rubygems.org/
specs:
Ascii85 (1.1.0)
Ascii85 (2.0.1)
aasm (5.5.0)
concurrent-ruby (~> 1.0)
actioncable (7.2.2.1)
Expand Down Expand Up @@ -531,14 +531,9 @@ GEM
google-cloud-env (2.2.1)
faraday (>= 1.0, < 3.a)
google-logging-utils (0.1.0)
google-protobuf (4.28.3)
google-protobuf (4.29.2)
bigdecimal
rake (>= 13)
google-protobuf (4.28.3-java)
bigdecimal
ffi (~> 1)
ffi-compiler (~> 1)
rake (>= 13)
googleauth (1.12.2)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.2)
Expand Down Expand Up @@ -761,8 +756,8 @@ GEM
safe_shell (>= 1.0.3, < 2.0)
pdf-inspector (1.3.0)
pdf-reader (>= 1.0, < 3.0.a)
pdf-reader (2.12.0)
Ascii85 (~> 1.0)
pdf-reader (2.13.0)
Ascii85 (>= 1.0, < 3.0, != 2.0.0)
afm (~> 0.2.1)
hashery (~> 2.0)
ruby-rc4
Expand Down
12 changes: 10 additions & 2 deletions app/models/health_care_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,16 @@ def send_failure_email

def form_matches_schema
if form.present?
JSON::Validator.fully_validate(VetsJsonSchema::SCHEMAS[self.class::FORM_ID], parsed_form).each do |v|
errors.add(:form, v.to_s)
schema = VetsJsonSchema::SCHEMAS[self.class::FORM_ID]
begin
JSON::Validator.fully_validate(schema, parsed_form).each do |v|
errors.add(:form, v.to_s)
end
rescue => e
PersonalInformationLog.create(data: { schema:, parsed_form: },
error_class: 'HealthCareApplication FormValidationError')
Rails.logger.error("[#{FORM_ID}] Error during schema validation!", { error: e.message, schema: })
raise
end
end
end
Expand Down
15 changes: 9 additions & 6 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class RemoveOldIndicesFromPoaForms < ActiveRecord::Migration[7.1]
def change
remove_index :ar_power_of_attorney_forms, name: 'idx_on_city_bidx_state_bidx_zipcode_bidx_a85b76f9bc', column: [:city_bidx, :state_bidx, :zipcode_bidx]
remove_index :ar_power_of_attorney_forms, name: 'index_ar_power_of_attorney_forms_on_zipcode_bidx', column: :zipcode_bidx
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveColumnsFromPoaForms < ActiveRecord::Migration[7.1]
def change
safety_assured { remove_columns :ar_power_of_attorney_forms, :city_bidx, :state_bidx, :zipcode_bidx, type: :string }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class AddColumnsToPoaForms < ActiveRecord::Migration[7.1]
def change
add_column :ar_power_of_attorney_forms, :claimant_city_ciphertext, :string, null: false
add_column :ar_power_of_attorney_forms, :claimant_city_bidx, :string, null: false

add_column :ar_power_of_attorney_forms, :claimant_state_code_ciphertext, :string, null: false
add_column :ar_power_of_attorney_forms, :claimant_state_code_bidx, :string, null: false

add_column :ar_power_of_attorney_forms, :claimant_zip_code_ciphertext, :string, null: false
add_column :ar_power_of_attorney_forms, :claimant_zip_code_bidx, :string, null: false
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddNewIndexToPoaForms < ActiveRecord::Migration[7.1]
disable_ddl_transaction!

def change
add_index :ar_power_of_attorney_forms,
[:claimant_city_bidx, :claimant_state_code_bidx, :claimant_zip_code_bidx],
algorithm: :concurrently
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddClaimantTypeToPoaRequests < ActiveRecord::Migration[7.1]
def change
add_column :ar_power_of_attorney_requests, :claimant_type, :string, null: false
end
end
26 changes: 26 additions & 0 deletions spec/models/health_care_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,32 @@
expect_attr_valid(health_care_application, attr)
end
end

context 'schema validation raises an exception' do
let(:health_care_application) { build(:health_care_application) }
let(:exception) { StandardError.new('Some exception') }

before do
allow(PersonalInformationLog).to receive(:create)
allow(JSON::Validator).to receive(:fully_validate).and_raise(exception)
end

it 'logs exception and raises exception' do
expect(PersonalInformationLog).to receive(:create).with(
data: {
schema: VetsJsonSchema::SCHEMAS[form_id],
parsed_form: health_care_application.parsed_form
},
error_class: 'HealthCareApplication FormValidationError'
)
expect(Rails.logger).to receive(:error)
.with("[#{form_id}] Error during schema validation!", {
error: exception.message,
schema: VetsJsonSchema::SCHEMAS[form_id]
})
expect { health_care_application.valid? }.to raise_error(exception.class, exception.message)
end
end
end

describe '#process!' do
Expand Down

0 comments on commit f2ef47c

Please sign in to comment.