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

mobile efolder fix #19041

Merged
merged 19 commits into from
Oct 25, 2024
8 changes: 4 additions & 4 deletions modules/mobile/app/models/mobile/v0/adapters/efolder.rb
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stubbed efolder spec data was incorrect

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class Efolder
def self.parse(documents)
documents.map do |document|
Mobile::V0::Efolder.new(
id: document['document_id'],
doc_type: document['doc_type'],
type_description: document['type_description'],
received_at: document['received_at']
id: document[:document_id],
doc_type: document[:doc_type],
type_description: document[:type_description],
received_at: document[:received_at]
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def create_events_for_documents(attributes)
tracked_item_id: document['trackedItemId'],
upload_date: document['uploadDate'],
file_type: document['documentTypeLabel'],
filename: document['originalFileName']
filename: document['originalFileName'],
document_id: document['documentId']
)
end
end
Expand Down Expand Up @@ -173,7 +174,8 @@ def create_documents(documents)
# no document type field available
document_type: nil,
filename: document['originalFileName'],
upload_date: document['uploadDate']
upload_date: document['uploadDate'],
document_id: document['documentId']
}
ClaimDocument.new(document_hash)
end
Expand Down
1 change: 1 addition & 0 deletions modules/mobile/app/models/mobile/v0/claim_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ClaimDocument < Common::Resource
attribute :document_type, Types::Nil
attribute :filename, Types::String
attribute :upload_date, Types::Date
attribute :document_id, Types::String
end
end
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to match old EVSS formatting, untracked documents are created as an event, not a claim document.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ClaimEventTimeline < Common::Resource
attribute :file_type, Types::String.optional.default(nil)
attribute :document_type, Types::String.optional.default(nil)
attribute :filename, Types::String.optional.default(nil)
attribute :document_id, Types::String.optional.default(nil)
end
end
end
36 changes: 18 additions & 18 deletions modules/mobile/docs/index.html

Large diffs are not rendered by default.

87 changes: 50 additions & 37 deletions modules/mobile/docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -11519,6 +11519,10 @@
"upload_date": {
"type": "string",
"example": "2023-03-01"
},
"document_id": {
"type": "string",
"example": "{6A6DFA79-4EC9-4E58-9653-25BDCFB06A03}"
}
}
},
Expand Down Expand Up @@ -11602,6 +11606,12 @@
"filename": {
"type": "string",
"example": "7B434B58-477C-4379-816F-05E6D3A10487.pdf"
},
"document_id": {
"type": "string",
"description": "Only used for other_documents_list type event for untracked documents",
"nullable": true,
"example": "{6A6DFA79-4EC9-4E58-9653-25BDCFB06A03}"
}
}
},
Expand Down Expand Up @@ -18131,43 +18141,46 @@
],
"properties": {
"data": {
"type": "object",
"additionalProperties": false,
"required": [
"type",
"id",
"attributes"
],
"properties": {
"type": {
"type": "string",
"example": "efolder_document"
},
"id": {
"type": "string",
"example": "{23fe358d-6e82-4541-804c-ce7562ba28f4}",
"description": "document id"
},
"attributes": {
"type": "object",
"additionalProperties": false,
"required": [
"doc_type",
"type_description",
"received_at"
],
"properties": {
"doc_type": {
"type": "string",
"example": 1215
},
"type_description": {
"type": "string",
"example": "DMC - Debt Increase Letter"
},
"received_at": {
"type": "date",
"example": "2020-05-28"
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"id",
"type",
"attributes"
],
"properties": {
"id": {
"type": "string",
"example": "{23fe358d-6e82-4541-804c-ce7562ba28f4}",
"description": "document id"
},
"type": {
"type": "string",
"example": "efolder_document"
},
"attributes": {
"type": "object",
"additionalProperties": false,
"required": [
"doc_type",
"type_description",
"received_at"
],
"properties": {
"doc_type": {
"type": "string",
"example": 1215
},
"type_description": {
"type": "string",
"example": "DMC - Debt Increase Letter"
},
"received_at": {
"type": "date",
"example": "2020-05-28"
}
}
}
}
Expand Down
64 changes: 33 additions & 31 deletions modules/mobile/docs/schemas/Efolder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,36 @@ required:
- data
properties:
data:
type: object
additionalProperties: false
required:
- type
- id
- attributes
properties:
type:
type: string
example: efolder_document
id:
type: string
example: "{23fe358d-6e82-4541-804c-ce7562ba28f4}"
description: document id
attributes:
type: object
additionalProperties: false
required:
- doc_type
- type_description
- received_at
properties:
doc_type:
type: string
example: 1215
type_description:
type: string
example: DMC - Debt Increase Letter
received_at:
type: date
example: 2020-05-28
type: array
items:
type: object
additionalProperties: false
required:
- id
- type
- attributes
properties:
id:
type: string
example: "{23fe358d-6e82-4541-804c-ce7562ba28f4}"
description: document id
type:
type: string
example: efolder_document
attributes:
type: object
additionalProperties: false
required:
- doc_type
- type_description
- received_at
properties:
doc_type:
type: string
example: 1215
type_description:
type: string
example: DMC - Debt Increase Letter
received_at:
type: date
example: 2020-05-28
3 changes: 3 additions & 0 deletions modules/mobile/docs/schemas/claimDocument.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ properties:
upload_date:
type: string
example: '2023-03-01'
document_id:
type: string
example: '{6A6DFA79-4EC9-4E58-9653-25BDCFB06A03}'
7 changes: 6 additions & 1 deletion modules/mobile/docs/schemas/claimEventTimeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ properties:
example: null
filename:
type: string
example: '7B434B58-477C-4379-816F-05E6D3A10487.pdf'
example: '7B434B58-477C-4379-816F-05E6D3A10487.pdf'
document_id:
type: string
jperk51 marked this conversation as resolved.
Show resolved Hide resolved
description: 'Only used for other_documents_list type event for untracked documents'
nullable: true
example: '{6A6DFA79-4EC9-4E58-9653-25BDCFB06A03}'
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def claim_data
it 'returns expected other documents in events_timeline field' do
other_documents_list = under_review_claim[:events_timeline].select { |event| event[:type] == :other_documents_list }
expect(other_documents_list.size).to eq(13)
expect(other_documents_list.map(&:document_id)).to include('{7AF4C5E0-EBCE-49B2-9544-999ECA2904FD}')
end

it 'returns expected filed event in events_timeline field' do
Expand Down Expand Up @@ -68,12 +69,14 @@ def claim_data
file_type: 'Civilian Police Reports',
document_type: nil,
filename: '7B434B58-477C-4379-816F-05E6D3A10487.pdf',
upload_date: '2023-03-01' }],
upload_date: '2023-03-01',
document_id: '{883B6CC8-D726-4911-9C65-2EB360E12F52}' }],
upload_date: '2023-03-01',
date: Date.new(2023, 3, 1),
file_type: nil,
document_type: nil,
filename: nil })
filename: nil,
document_id: nil })
end

context 'with claim in phase CLAIM_RECEIVED' do
Expand Down
17 changes: 11 additions & 6 deletions modules/mobile/spec/requests/mobile/v0/efolder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
let!(:user) { sis_user }

context 'with working upstream service' do
stub_efolder_documents(:index)
stub_efolder_index_documents

let!(:efolder_response) do
{ 'data' => [{ 'id' => '{93631483-E9F9-44AA-BB55-3552376400D8}', 'type' => 'efolder_document',
'attributes' => { 'docType' => '1215',
'typeDescription' => 'DMC - Debt Increase Letter',
'receivedAt' => '2020-05-28' } }] }
{ 'data' => [{ 'id' => '{73CD7B28-F695-4337-BBC1-2443A913ACF6}', 'type' => 'efolder_document',
'attributes' => { 'docType' => '702',
'typeDescription' =>
'Disability Benefits Questionnaire (DBQ) - Veteran Provided',
'receivedAt' => '2024-09-13' } },
{ 'id' => '{EF7BF420-7E49-4FA9-B14C-CE5F6225F615}', 'type' => 'efolder_document',
'attributes' => { 'docType' => '45',
'typeDescription' => 'Military Personnel Record',
'receivedAt' => '2024-09-13' } }] }
end

it 'and a result that matches our schema is successfully returned with the 200 status' do
Expand Down Expand Up @@ -48,7 +53,7 @@
let!(:user) { sis_user }

context 'with working upstream service' do
stub_efolder_documents(:show)
stub_efolder_show_document
it 'returns expected document' do
post "/mobile/v0/efolder/documents/#{CGI.escape(document_id)}/download", params: { file_name: 'test' },
headers: sis_headers
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/swagger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@
end

context 'efolder index' do
stub_efolder_documents(:index)
stub_efolder_index_documents

it 'validates the route' do
expect(subject).to validate(
Expand All @@ -668,7 +668,7 @@
end

context 'efolder show' do
stub_efolder_documents(:show)
stub_efolder_show_document

it 'validates the route' do
expect(subject).to validate(
Expand Down
18 changes: 15 additions & 3 deletions spec/requests/v0/efolder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,28 @@
end

describe 'GET /v0/efolder' do
stub_efolder_documents(:index)
stub_efolder_index_documents
let(:expected_response) do
[
{ 'document_id' => '{73CD7B28-F695-4337-BBC1-2443A913ACF6}',
'doc_type' => '702',
'type_description' => 'Disability Benefits Questionnaire (DBQ) - Veteran Provided',
'received_at' => '2024-09-13' },
{ 'document_id' => '{EF7BF420-7E49-4FA9-B14C-CE5F6225F615}',
'doc_type' => '45',
'type_description' => 'Military Personnel Record',
'received_at' => '2024-09-13' }
]
end

it 'shows all documents available to the veteran' do
get '/v0/efolder'
expect(JSON.parse(response.body)).to eq(list_documents_res)
expect(JSON.parse(response.body)).to eq(expected_response)
end
end

describe 'GET /v0/efolder/{id}' do
stub_efolder_documents(:show)
stub_efolder_show_document

it 'sends the doc pdf' do
get "/v0/efolder/#{CGI.escape(document_id)}", params: { filename: 'test.pdf' }
Expand Down
Loading
Loading