Skip to content

Commit

Permalink
Finish specs for EVSS path, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ajones446 committed Oct 28, 2024
1 parent 3c20b4e commit 84c8363
Showing 1 changed file with 58 additions and 44 deletions.
102 changes: 58 additions & 44 deletions spec/sidekiq/evss/disability_compensation_form/submit_form0781_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,34 @@

it 'uploads the 0781 documents to Lighthouse' do
# 0781
allow_any_instance_of(described_class).to receive(:generate_stamp_pdf).with(parsed_0781_form,
submission.submitted_claim_id, '21-0781').and_return(path_to_0781_fixture)
allow_any_instance_of(described_class)
.to receive(:generate_stamp_pdf)
.with(parsed_0781_form, submission.submitted_claim_id, '21-0781')
.and_return(path_to_0781_fixture)

allow_any_instance_of(LighthouseSupplementalDocumentUploadProvider).to receive(:generate_upload_document).and_return(lighthouse_0781_document)
allow_any_instance_of(LighthouseSupplementalDocumentUploadProvider)
.to receive(:generate_upload_document)
.and_return(lighthouse_0781_document)

allow(File).to receive(:delete).and_return(nil)

expect(BenefitsDocuments::Form526::UploadSupplementalDocumentService).to receive(:call).with(sample_0781_file_read,
lighthouse_0781a_document)
expect(BenefitsDocuments::Form526::UploadSupplementalDocumentService)
.to receive(:call)
.with(sample_0781_file_read, lighthouse_0781a_document)

# 0781a
allow_any_instance_of(described_class).to receive(:generate_stamp_pdf).with(parsed_0781a_form,
submission.submitted_claim_id, '21-0781a').and_return(path_to_0781a_fixture)
allow_any_instance_of(described_class)
.to receive(:generate_stamp_pdf)
.with(parsed_0781a_form, submission.submitted_claim_id, '21-0781a')
.and_return(path_to_0781a_fixture)

allow_any_instance_of(LighthouseSupplementalDocumentUploadProvider).to receive(:generate_upload_document).and_return(lighthouse_0781a_document)
allow_any_instance_of(LighthouseSupplementalDocumentUploadProvider)
.to receive(:generate_upload_document)
.and_return(lighthouse_0781a_document)

expect(BenefitsDocuments::Form526::UploadSupplementalDocumentService).to receive(:call).with(sample_0781a_file_read,
lighthouse_0781a_document)
expect(BenefitsDocuments::Form526::UploadSupplementalDocumentService)
.to receive(:call)
.with(sample_0781a_file_read, lighthouse_0781a_document)

perform_upload
end
Expand Down Expand Up @@ -281,19 +291,22 @@
before do
Flipper.disable(:disability_compensation_upload_0781_to_lighthouse)
allow(EVSS::DocumentsService).to receive(:new) { client_stub }
allow_any_instance_of(EVSS::DocumentsService).to receive(:upload)

allow_any_instance_of(described_class).to receive(:generate_stamp_pdf).with(parsed_0781_form,
submission.submitted_claim_id, '21-0781').and_return(path_to_0781_fixture)

allow_any_instance_of(EVSSSupplementalDocumentUploadProvider).to receive(:generate_upload_document).with('simple_0781.pdf').and_return(evss_claim_0781_document)

allow(client_stub).to receive(:upload)
allow_any_instance_of(described_class)
.to receive(:generate_stamp_pdf).with(parsed_0781_form, submission.submitted_claim_id, '21-0781')
.and_return(path_to_0781_fixture)
allow_any_instance_of(EVSSSupplementalDocumentUploadProvider)
.to receive(:generate_upload_document)
.with('simple_0781.pdf')
.and_return(evss_claim_0781_document)
allow(File).to receive(:delete).and_return(nil)

allow_any_instance_of(described_class).to receive(:generate_stamp_pdf).with(parsed_0781a_form,
submission.submitted_claim_id, '21-0781a').and_return(path_to_0781a_fixture)

allow_any_instance_of(EVSSSupplementalDocumentUploadProvider).to receive(:generate_upload_document).with('simple.pdf').and_return(evss_claim_0781a_document)
allow_any_instance_of(described_class)
.to receive(:generate_stamp_pdf)
.with(parsed_0781a_form, submission.submitted_claim_id, '21-0781a')
.and_return(path_to_0781a_fixture)
allow_any_instance_of(EVSSSupplementalDocumentUploadProvider)
.to receive(:generate_upload_document).with('simple.pdf')
.and_return(evss_claim_0781a_document)
end

it 'uploads the 0781 documents to EVSS' do
Expand All @@ -304,33 +317,34 @@
perform_upload
end

# TODO: it 'logs the upload attempt with the correct job prefix' do
# expect(StatsD).to receive(:increment).with(
# "#{expected_statsd_metrics_prefix}.upload_attempt"
# ).twice # For 0781 and 0781a
it 'logs the upload attempt with the correct job prefix' do
allow(client_stub).to receive(:upload)
expect(StatsD).to receive(:increment).with(
"#{expected_statsd_metrics_prefix}.upload_attempt"
).twice # For 0781 and 0781a

# perform_upload
# end
perform_upload
end

# TODO: it 'increments the correct StatsD success metric' do
# expect(StatsD).to receive(:increment).with(
# "#{expected_statsd_metrics_prefix}.upload_success"
# ).twice # For 0781 and 0781a
it 'increments the correct StatsD success metric' do
allow(client_stub).to receive(:upload)
expect(StatsD).to receive(:increment).with(
"#{expected_statsd_metrics_prefix}.upload_success"
).twice # For 0781 and 0781a

# perform_upload
# end
perform_upload
end

context 'when an upload raises an EVSS response error' do
# TODO: it 'logs an upload error' do
# allow_any_instance_of(EVSS::DocumentsService).to receive(:upload)
# .and_raise(EVSS::ErrorMiddleware::EVSSError)
# expect_any_instance_of(EVSSSupplementalDocumentUploadProvider).to receive(:log_upload_failure)

# expect do
# subject.perform_async(submission.id)
# described_class.drain
# end.to raise_error(EVSS::ErrorMiddleware::EVSSError)
# end
it 'logs an upload error' do
allow(client_stub).to receive(:upload).and_raise(EVSS::ErrorMiddleware::EVSSError)
expect_any_instance_of(EVSSSupplementalDocumentUploadProvider).to receive(:log_upload_failure)

expect do
subject.perform_async(submission.id)
described_class.drain
end.to raise_error(EVSS::ErrorMiddleware::EVSSError)
end
end
end
end
Expand Down

0 comments on commit 84c8363

Please sign in to comment.