-
Notifications
You must be signed in to change notification settings - Fork 57
/
bd_spec.rb
45 lines (36 loc) · 1.38 KB
/
bd_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
require 'rails_helper'
require_relative '../../rails_helper'
describe ClaimsApi::BD do
subject { described_class.new }
before do
allow_any_instance_of(ClaimsApi::V2::BenefitsDocuments::Service)
.to receive(:get_auth_token).and_return('some-value-here')
end
describe '#upload' do
let(:claim) { create(:auto_established_claim, evss_id: 600_400_688) }
let(:pdf_path) { 'modules/claims_api/spec/fixtures/21-526EZ.pdf' }
it 'uploads a document to BD' do
VCR.use_cassette('claims_api/bd/upload') do
result = subject.upload(claim:, pdf_path:)
expect(result).to be_a Hash
expect(result[:data][:success]).to be true
end
end
it 'uploads an attachment to BD' do
result = subject.send(:generate_upload_body, claim:, doc_type: 'L023', original_filename: '21-526EZ.pdf',
pdf_path:)
js = JSON.parse(result[:parameters].read)
expect(js['data']['docType']).to eq 'L023'
end
end
describe '#search', vcr: 'claims_api/v2/claims_show' do
let(:claim_id) { '600397218' }
let(:file_number) { '796378782' }
it 'locates claim documents when provided a fileNumber and claimId' do
result = subject.search(claim_id, file_number)
expect(result).to be_a Hash
expect(result[:data][:documents]).to be_truthy
end
end
end