Skip to content

Commit

Permalink
Release R2.2.0 FY24Q4.2.0
Browse files Browse the repository at this point in the history
* Fixes error message on line 16 function: invalid_file_number

* Updates rspec test to correct error message

---------

Co-authored-by: VaForceZ <149601263+VaForceZ@users.noreply.github.com>
  • Loading branch information
ronwabVa and VaForceZ authored Aug 12, 2024
1 parent 9853eae commit f22dc4e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v2/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def vso_denied_record
end

def invalid_file_number
render json: { status: "File number is invalid. Veteran IDs must be 8 or more characters and contain only numbers." }, status: 400
render json: { status: "File number is invalid. Veteran IDs must be at least 8 characters, no more than 9 and contain only numbers." }, status: 400
end

def verify_veteran_file_number
Expand Down
31 changes: 22 additions & 9 deletions spec/controllers/api_v2_application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def index
get :index

expect(response).to be_successful
expect(body).to eq(status: veteran_id)
expect(body).to eq(status: veteran_id)
end

context "user is VSO" do
Expand All @@ -96,7 +96,7 @@ def index
end
end
allow_any_instance_of(BGSService).to receive(:fetch_poa_by_file_number)
.with(veteran_id) { nil }
.with(veteran_id) { nil }
end

it "responds with error" do
Expand All @@ -112,11 +112,11 @@ def index
context "user has POA for Claimant" do
before do
allow_any_instance_of(BGSService).to receive(:fetch_poa_by_participant_id)
.with(claimant_participant_id) { claimants_poa_response }
.with(claimant_participant_id) { claimants_poa_response }
allow_any_instance_of(BGSService).to receive(:fetch_claims_for_file_number)
.with(veteran_id) { benefit_claims_response }
.with(veteran_id) { benefit_claims_response }
allow_any_instance_of(BGSService).to receive(:fetch_poa_org_record)
.with(poa_participant_id) { org_poa_response }
.with(poa_participant_id) { org_poa_response }
end

it "responds with success" do
Expand All @@ -130,7 +130,7 @@ def index
context "user does not have POA for Claimant" do
before do
allow_any_instance_of(BGSService).to receive(:fetch_poa_by_participant_id)
.with(claimant_participant_id) { nil }
.with(claimant_participant_id) { nil }
end

it "responds with error" do
Expand All @@ -153,9 +153,9 @@ def index
end
end
allow_any_instance_of(BGSService).to receive(:fetch_poa_by_file_number)
.with(veteran_id) { claimants_poa_response }
.with(veteran_id) { claimants_poa_response }
allow_any_instance_of(BGSService).to receive(:fetch_poa_org_record)
.with(poa_participant_id) { org_poa_response }
.with(poa_participant_id) { org_poa_response }
end

it "responds with success" do
Expand All @@ -176,14 +176,27 @@ def index
end
end
end

it "responds with error" do
get :index

expect(response).to_not be_successful
expect(body[:status]).to include("This efolder contains sensitive information")
end
end
context 'when calling invalid_file_number' do
before do
routes.draw { get 'index' => 'api/v2/application#index' }
allow(controller).to receive(:bgs_service).and_return(double("BGSService", valid_file_number?: false))
get :index
end

it 'returns JSON with error message' do
expected_response = {
status: "File number is invalid. Veteran IDs must be at least 8 characters, no more than 9 and contain only numbers."
}
expect(JSON.parse(response.body, symbolize_names: true)).to eq(expected_response)
end
end
end
end
end

0 comments on commit f22dc4e

Please sign in to comment.