Skip to content

Commit

Permalink
Revert "Remove unused validate_upload_document method from doc upload…
Browse files Browse the repository at this point in the history
… providers"

This reverts commit 130d26c.
  • Loading branch information
NB28VT committed Nov 27, 2024
1 parent 1aabb58 commit 107edd4
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 107edd4

Please sign in to comment.