Skip to content

Commit

Permalink
Update Gem Version and Get Specs Passing
Browse files Browse the repository at this point in the history
  • Loading branch information
tradesmanhelix committed Jul 18, 2024
1 parent 2cf7389 commit 7505859
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ GIT

GIT
remote: https://github.com/department-of-veterans-affairs/ruby_claim_evidence_api.git
revision: aa3a6f65a68523d8fd6bf887e1f66cd483bea41d
revision: 389414d4f2b90adbe97749f874d71af82bfb7e21
branch: feature/APPEALS-43121-efolder
specs:
ruby_claim_evidence_api (0.1.0)
Expand All @@ -76,6 +76,7 @@ GIT
faraday
faraday-multipart
httpi
rack (< 3)
railties
webmock (~> 3.11.0)

Expand Down
2 changes: 1 addition & 1 deletion app/services/external_api/vbms_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def self.fetch_document_series_for(appeal)

def self.update_document_in_vbms(appeal, uploadable_document)
if FeatureToggle.enabled?(:use_ce_api)
file_update_payload = Models::FileUpdatePayload.new(
file_update_payload = ClaimEvidenceFileUpdatePayload.new(
date_va_received_document: Time.zone.now,
document_type_id: uploadable_document.document_type_id,
file_content: File.read(uploadable_document.pdf_location),
Expand Down
42 changes: 30 additions & 12 deletions spec/services/external_api/vbms_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,26 @@
end

describe ".update_document_in_vbms" do
let(:fake_document) do
instance_double(
UpdateDocumentInVbms,
document_type_id: 1,
pdf_location: "/path/to/test/location",
source: "my_source",
document_version_reference_id: "12345"
)
end
let(:appeal) { create(:appeal) }

context "with use_ce_api feature toggle enabled" do
before { FeatureToggle.enable!(:use_ce_api) }
after { FeatureToggle.disable!(:use_ce_api) }

let(:fake_document) do
instance_double(
UpdateDocumentInVbms,
document_type_id: 1,
pdf_location: "/path/to/test/location",
source: "my_source",
document_version_reference_id: "12345"
)
end
let(:appeal) { create(:appeal) }
let(:mock_file_update_payload) { instance_double(Models::FileUpdatePayload) }
let(:mock_file_update_payload) { instance_double(ClaimEvidenceFileUpdatePayload) }

it "calls the CE API" do
expect(File).to receive(:read).and_return("pdf byte string")
expect(Models::FileUpdatePayload).to receive(:new).and_return(mock_file_update_payload)
expect(ClaimEvidenceFileUpdatePayload).to receive(:new).and_return(mock_file_update_payload)
expect(VeteranFileUpdater)
.to receive(:update_veteran_file)
.with(
Expand All @@ -110,5 +111,22 @@
described.update_document_in_vbms(appeal, fake_document)
end
end

context "with use_ce_api feature toggle disabled" do
let(:mock_init_update_response) { double(updated_document_token: "12345") }

it "calls the SOAP API implementation" do
expect(FeatureToggle).to receive(:enabled?).with(:use_ce_api).and_return(false)
expect(described).to receive(:init_vbms_client)
expect(described).to receive(:initialize_update).and_return(mock_init_update_response)
expect(described).to receive(:update_document).with(
appeal.veteran_file_number,
"12345",
"/path/to/test/location"
)

described.update_document_in_vbms(appeal, fake_document)
end
end
end
end

0 comments on commit 7505859

Please sign in to comment.