-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
253 | mobile vshe connection (#21024)
* 253 | Added route, controller, and specs for VetVerificationStatus * 253 | Updated mobile docs with new VetVerificationStatus route * 253 | Add description to json docs * Remove debug puts * 253 | Add schema to openapi.json * 253 | Updated parameters in docs --------- Co-authored-by: ATeal <[email protected]>
- Loading branch information
1 parent
6f5da72
commit a564784
Showing
6 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
modules/mobile/app/controllers/mobile/v0/vet_verification_statuses_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mobile | ||
module V0 | ||
class VetVerificationStatusesController < ApplicationController | ||
def show | ||
response = service.get_vet_verification_status(@current_user.icn) | ||
response['data']['id'] = '' | ||
|
||
render json: response | ||
end | ||
|
||
private | ||
|
||
def service | ||
@service ||= VeteranVerification::Service.new | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
type: object | ||
additionalProperties: false | ||
required: | ||
- data | ||
properties: | ||
data: | ||
type: object | ||
additionalProperties: false | ||
required: | ||
- attributes | ||
properties: | ||
attributes: | ||
type: object | ||
additionalProperties: false | ||
required: | ||
- veteranStatus | ||
properties: | ||
veteranStatus: | ||
type: string | ||
example: confirmed | ||
notConfirmedReason: | ||
type: string | ||
example: PERSON_NOT_FOUND |
81 changes: 81 additions & 0 deletions
81
modules/mobile/spec/requests/mobile/v0/vet_verification_statuses_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# frozen_string_literal: true | ||
|
||
# require 'rails_helper' | ||
require_relative '../../../support/helpers/rails_helper' | ||
|
||
RSpec.describe 'Mobile::V0::VetVerificationStatuses', type: :request do | ||
let!(:user) { sis_user(icn: '1012667145V762142') } | ||
|
||
before do | ||
sign_in_as(user) | ||
allow_any_instance_of(VeteranVerification::Configuration).to receive(:access_token).and_return('blahblech') | ||
end | ||
|
||
describe '#show' do | ||
context 'when successful' do | ||
it 'returns a status of 200' do | ||
VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do | ||
get '/mobile/v0/vet_verification_status', headers: sis_headers | ||
end | ||
|
||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'returns veteran confirmation status' do | ||
VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do | ||
get '/mobile/v0/vet_verification_status', headers: sis_headers | ||
end | ||
|
||
parsed_body = JSON.parse(response.body) | ||
expect(parsed_body['data']['attributes']['veteranStatus']).to eq('confirmed') | ||
end | ||
|
||
it 'removes the Veterans ICN from the response before sending' do | ||
VCR.use_cassette('lighthouse/veteran_verification/status/200_show_response') do | ||
get '/mobile/v0/vet_verification_status', headers: sis_headers | ||
end | ||
|
||
parsed_body = JSON.parse(response.body) | ||
expect(parsed_body['data']['id']).to eq('') | ||
end | ||
end | ||
|
||
context 'when not authorized' do | ||
it 'returns a status of 401' do | ||
VCR.use_cassette('lighthouse/veteran_verification/status/401_response') do | ||
get '/mobile/v0/vet_verification_status', headers: sis_headers | ||
end | ||
|
||
expect(response).to have_http_status(:unauthorized) | ||
end | ||
end | ||
|
||
context 'when ICN not found' do | ||
let(:user) { sis_user(icn: '1012667145V762141') } | ||
|
||
before do | ||
sign_in_as(user) | ||
allow_any_instance_of(VeteranVerification::Configuration).to receive(:access_token).and_return('blahblech') | ||
end | ||
|
||
it 'returns a status of 200' do | ||
VCR.use_cassette('lighthouse/veteran_verification/status/200_person_not_found_response') do | ||
get '/mobile/v0/vet_verification_status', headers: sis_headers | ||
end | ||
|
||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'returns a person_not_found reason' do | ||
VCR.use_cassette('lighthouse/veteran_verification/status/200_person_not_found_response') do | ||
get '/mobile/v0/vet_verification_status', headers: sis_headers | ||
end | ||
|
||
parsed_body = JSON.parse(response.body) | ||
expect(parsed_body['data']['attributes']['veteranStatus']).to eq('not confirmed') | ||
expect(parsed_body['data']['attributes']['notConfirmedReason']).to eq('PERSON_NOT_FOUND') | ||
expect(parsed_body['data']['message']).to eq(VeteranVerification::Constants::NOT_FOUND_MESSAGE) | ||
end | ||
end | ||
end | ||
end |