From 107edd49418d9fc6ca36c3aa58b1642817a4090c Mon Sep 17 00:00:00 2001 From: Nathan Burgess Date: Wed, 27 Nov 2024 12:40:24 -0500 Subject: [PATCH] Revert "Remove unused validate_upload_document method from doc upload providers" This reverts commit 130d26cc8c25531ec31c4d5c8997b316c0241ff9. --- ...evss_supplemental_document_upload_provider.rb | 9 +++++++++ ...ouse_supplemental_document_upload_provider.rb | 9 +++++++++ .../supplemental_document_upload_provider.rb | 4 ++++ ...supplemental_document_upload_provider_spec.rb | 15 +++++++++++++++ ...supplemental_document_upload_provider_spec.rb | 16 ++++++++++++++++ ...supplemental_document_upload_provider_spec.rb | 6 ++++++ .../supplemental_document_upload_provider.rb | 1 + 7 files changed, 60 insertions(+) diff --git a/lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb b/lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb index 02f5f37249a..44f39b9e849 100644 --- a/lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb +++ b/lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider.rb @@ -35,6 +35,15 @@ def generate_upload_document(file_name) ) end + # Takes the necessary validation steps to ensure the document metadata is sufficient + # for submission to EVSS + # + # @param evss_claim_document [EVSSClaimDocument] + # @retrun [boolean] + def validate_upload_document(evss_claim_document) + evss_claim_document.valid? + end + # Initializes and uploads via our EVSS Document Service API wrapper # # @param evss_claim_document diff --git a/lib/disability_compensation/providers/document_upload/lighthouse_supplemental_document_upload_provider.rb b/lib/disability_compensation/providers/document_upload/lighthouse_supplemental_document_upload_provider.rb index 3eb93183681..8261b29634d 100644 --- a/lib/disability_compensation/providers/document_upload/lighthouse_supplemental_document_upload_provider.rb +++ b/lib/disability_compensation/providers/document_upload/lighthouse_supplemental_document_upload_provider.rb @@ -46,6 +46,15 @@ def generate_upload_document(file_name) ) end + # Takes the necessary validation steps to ensure the document metadata is sufficient + # for submission to Lighthouse + # + # @param lighthouse_document [LighthouseDocument] + # @return [boolean] + def validate_upload_document(lighthouse_document) + lighthouse_document.valid? + end + # Uploads the supplied file to the Lighthouse Benefits Documents API # # @param lighthouse_document [LighthouseDocument] diff --git a/lib/disability_compensation/providers/document_upload/supplemental_document_upload_provider.rb b/lib/disability_compensation/providers/document_upload/supplemental_document_upload_provider.rb index fae523d3ae2..f1b48ca29c0 100644 --- a/lib/disability_compensation/providers/document_upload/supplemental_document_upload_provider.rb +++ b/lib/disability_compensation/providers/document_upload/supplemental_document_upload_provider.rb @@ -14,6 +14,10 @@ def self.generate_upload_document(_file_name, _document_type) raise_not_implemented_error end + def self.validate_upload_document(_document) + raise_not_implemented_error + end + def self.submit_upload_document(_document, _file_body) raise_not_implemented_error end diff --git a/spec/lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider_spec.rb b/spec/lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider_spec.rb index 6f2fd9f2dae..ed6f7462be6 100644 --- a/spec/lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider_spec.rb +++ b/spec/lib/disability_compensation/providers/document_upload/evss_supplemental_document_upload_provider_spec.rb @@ -50,6 +50,21 @@ end end + describe '#validate_upload_document' do + context 'when the document is a valid EVSSClaimDocument' do + it 'returns true' do + expect(provider.validate_upload_document(evss_claim_document)).to eq(true) + end + end + + context 'when the document is an invalid EVSSClaimDocument' do + it 'returns false' do + allow_any_instance_of(EVSSClaimDocument).to receive(:valid?).and_return(false) + expect(provider.validate_upload_document(evss_claim_document)).to eq(false) + end + end + end + describe '#submit_upload_document' do context 'for a valid payload' do it 'submits the document via the EVSSDocumentService' do diff --git a/spec/lib/disability_compensation/providers/document_upload/lighthouse_supplemental_document_upload_provider_spec.rb b/spec/lib/disability_compensation/providers/document_upload/lighthouse_supplemental_document_upload_provider_spec.rb index 0ef65067167..02f1c9e84b4 100644 --- a/spec/lib/disability_compensation/providers/document_upload/lighthouse_supplemental_document_upload_provider_spec.rb +++ b/spec/lib/disability_compensation/providers/document_upload/lighthouse_supplemental_document_upload_provider_spec.rb @@ -69,6 +69,22 @@ end end + describe 'validate_upload_document' do + context 'when the document is a valid LighthouseDocument' do + it 'returns true' do + allow_any_instance_of(LighthouseDocument).to receive(:valid?).and_return(true) + expect(provider.validate_upload_document(lighthouse_document)).to eq(true) + end + end + + context 'when the document is an invalid LighthouseDocument' do + it 'returns false' do + allow_any_instance_of(LighthouseDocument).to receive(:valid?).and_return(false) + expect(provider.validate_upload_document(lighthouse_document)).to eq(false) + end + end + end + describe 'submit_upload_document' do it 'uploads the document via the UploadSupplementalDocumentService' do expect(BenefitsDocuments::Form526::UploadSupplementalDocumentService).to receive(:call) diff --git a/spec/lib/disability_compensation/providers/document_upload/supplemental_document_upload_provider_spec.rb b/spec/lib/disability_compensation/providers/document_upload/supplemental_document_upload_provider_spec.rb index b4c0eb1a6ea..bea3ab802c4 100644 --- a/spec/lib/disability_compensation/providers/document_upload/supplemental_document_upload_provider_spec.rb +++ b/spec/lib/disability_compensation/providers/document_upload/supplemental_document_upload_provider_spec.rb @@ -10,6 +10,12 @@ end.to raise_error NotImplementedError end + it 'raises an error if the validate_upload_document method is not implemented' do + expect do + subject.validate_upload_document(LighthouseDocument.new) + end.to raise_error NotImplementedError + end + it 'raises an error if the submit_upload_document method is not implemented' do expect do file_body = double diff --git a/spec/support/disability_compensation_form/shared_examples/supplemental_document_upload_provider.rb b/spec/support/disability_compensation_form/shared_examples/supplemental_document_upload_provider.rb index 455cc17e046..4c24ac416cc 100644 --- a/spec/support/disability_compensation_form/shared_examples/supplemental_document_upload_provider.rb +++ b/spec/support/disability_compensation_form/shared_examples/supplemental_document_upload_provider.rb @@ -8,5 +8,6 @@ let(:submission) { create(:form526_submission) } it { is_expected.to respond_to(:generate_upload_document) } + it { is_expected.to respond_to(:validate_upload_document) } it { is_expected.to respond_to(:submit_upload_document) } end