Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Vet File Update via Claim Evidence API #22194

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 18 additions & 3 deletions app/services/external_api/vbms_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,24 @@ def self.fetch_document_series_for(appeal)
end

def self.update_document_in_vbms(appeal, uploadable_document)
@vbms_client ||= init_vbms_client
response = initialize_update(appeal, uploadable_document)
update_document(appeal.veteran_file_number, response.updated_document_token, uploadable_document.pdf_location)
if FeatureToggle.enabled?(:use_ce_api)
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),
file_content_source: uploadable_document.source
)

VeteranFileUpdater.update_veteran_file(
veteran_file_number: appeal.veteran_file_number,
file_uuid: uploadable_document.document_version_reference_id,
file_update_payload: file_update_payload
)
else
@vbms_client ||= init_vbms_client
response = initialize_update(appeal, uploadable_document)
update_document(appeal.veteran_file_number, response.updated_document_token, uploadable_document.pdf_location)
end
end

def self.upload_document_to_vbms(appeal, uploadable_document)
Expand Down
3 changes: 3 additions & 0 deletions config/initializers/ruby_claim_evidence_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

VeteranFileFetcher = ExternalApi::VeteranFileFetcher
.new(use_canned_api_responses: ApplicationController.dependencies_faked?, logger: Rails.logger)

VeteranFileUpdater = ExternalApi::VeteranFileUpdater
.new(use_canned_api_responses: ApplicationController.dependencies_faked?, logger: Rails.logger)
51 changes: 51 additions & 0 deletions spec/services/external_api/vbms_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,55 @@
end
end
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(:mock_file_update_payload) { instance_double(ClaimEvidenceFileUpdatePayload) }

it "calls the CE API" do
expect(File).to receive(:read).and_return("pdf byte string")
expect(ClaimEvidenceFileUpdatePayload).to receive(:new).and_return(mock_file_update_payload)
expect(VeteranFileUpdater)
.to receive(:update_veteran_file)
.with(
veteran_file_number: appeal.veteran_file_number,
file_uuid: "12345",
file_update_payload: mock_file_update_payload
)

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
Loading