Skip to content

Commit

Permalink
Fix nil Series_id for GetDocumentContent (#22038)
Browse files Browse the repository at this point in the history
* Add series_id assignment to initial fetch from VBMS

* Wrap attribute assignment in feature toggle and added test case
  • Loading branch information
Kevma50287 authored and youfoundmanesh committed Oct 25, 2024
1 parent 947ff11 commit 2d3cdb1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
22 changes: 15 additions & 7 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,21 @@ def self.from_efolder(hash, file_number)
end

def self.from_vbms_document(vbms_document, file_number)
new(type: type_from_vbms_type(vbms_document.doc_type),
alt_types: (vbms_document.alt_doc_types || []).map { |type| ALT_TYPES[type] },
received_at: vbms_document.received_at,
upload_date: vbms_document.upload_date,
vbms_document_id: vbms_document.document_id,
filename: vbms_document.filename,
file_number: file_number)
document = new(
type: type_from_vbms_type(vbms_document.doc_type),
alt_types: (vbms_document.alt_doc_types || []).map { |type| ALT_TYPES[type] },
received_at: vbms_document.received_at,
upload_date: vbms_document.upload_date,
vbms_document_id: vbms_document.document_id,
filename: vbms_document.filename,
file_number: file_number
)

if FeatureToggle.enabled?(:use_ce_api)
document.assign_attributes(series_id: vbms_document.series_id)
end

document
end

def self.type_id(type)
Expand Down
13 changes: 13 additions & 0 deletions spec/models/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,19 @@
expect(subject.type).to eq("VA Form 20-0995 Supplemental Claim Application")
end
end

context "when use_ce_api Featuretoggle is enabled" do
before { FeatureToggle.enable!(:use_ce_api) }
let(:vbms_document) do
OpenStruct.new(
document_id: "1",
series_id: "2"
)
end
it "assigns the series_id" do
expect(subject.series_id).to eq("2")
end
end
end

context "content tests" do
Expand Down

0 comments on commit 2d3cdb1

Please sign in to comment.