Skip to content

Commit 602e153

Browse files
authored
Add test coverage to verify correct argument is passed to process_0781 (#20096)
* Add test coverage to verify correct argument is passed to process_0781 * Address review feedback (don't persist submission to db)
1 parent a4c4e9b commit 602e153

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

spec/sidekiq/evss/disability_compensation_form/submit_form0781_spec.rb

+48
Original file line numberDiff line numberDiff line change
@@ -861,4 +861,52 @@
861861
end
862862
end
863863
end
864+
describe '#get_docs' do
865+
let(:submission_id) { 1 }
866+
let(:uuid) { 'some-uuid' }
867+
let(:submission) { build(:form526_submission, id: submission_id) }
868+
let(:parsed_forms) do
869+
{
870+
'form0781' => { 'content_0781' => 'value_0781' },
871+
'form0781a' => { 'content_0781a' => 'value_0781a' },
872+
'form0781v2' => nil
873+
}
874+
end
875+
876+
before do
877+
allow(Form526Submission).to receive(:find_by).with(id: submission_id).and_return(submission)
878+
allow_any_instance_of(described_class).to receive(:parsed_forms).and_return(parsed_forms)
879+
allow_any_instance_of(described_class).to receive(:process_0781).and_return('file_path') # rubocop:disable Naming/VariableNumber
880+
end
881+
882+
it 'returns the correct file type and file objects' do
883+
result = subject.new.get_docs(submission_id, uuid)
884+
885+
expect(result).to eq([
886+
{ type: described_class::FORM_ID_0781,
887+
file: 'file_path' },
888+
{ type: described_class::FORM_ID_0781A,
889+
file: 'file_path' }
890+
])
891+
end
892+
893+
it 'does not include forms with no content' do
894+
result = subject.new.get_docs(submission_id, uuid)
895+
896+
expect(result).not_to include({ type: described_class::FORM_ID_0781V2,
897+
file: 'file_path' })
898+
end
899+
900+
it 'correctly discerns whether to process a 0781 or 0781a' do
901+
expect_any_instance_of(described_class).to receive(:process_0781).with(uuid, described_class::FORM_ID_0781, # rubocop:disable Naming/VariableNumber
902+
parsed_forms['form0781'], upload: false)
903+
expect_any_instance_of(described_class).to receive(:process_0781).with(uuid, described_class::FORM_ID_0781A, # rubocop:disable Naming/VariableNumber
904+
parsed_forms['form0781a'], upload: false)
905+
expect_any_instance_of(described_class).not_to receive(:process_0781).with(uuid, # rubocop:disable Naming/VariableNumber
906+
described_class::FORM_ID_0781V2,
907+
parsed_forms['form0781v2'],
908+
upload: false)
909+
subject.new.get_docs(submission_id, uuid)
910+
end
911+
end
864912
end

0 commit comments

Comments
 (0)