From f22dc4ecaab374c2ae1c72ee3a314fd63e898af9 Mon Sep 17 00:00:00 2001 From: Ron Wabukenda <130374706+ronwabVa@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:26:12 -0400 Subject: [PATCH] Release R2.2.0 FY24Q4.2.0 * 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> --- .../api/v2/application_controller.rb | 2 +- .../api_v2_application_controller_spec.rb | 31 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v2/application_controller.rb b/app/controllers/api/v2/application_controller.rb index 42310b095..f7f25cd24 100644 --- a/app/controllers/api/v2/application_controller.rb +++ b/app/controllers/api/v2/application_controller.rb @@ -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 diff --git a/spec/controllers/api_v2_application_controller_spec.rb b/spec/controllers/api_v2_application_controller_spec.rb index a6cda8d14..90390035e 100644 --- a/spec/controllers/api_v2_application_controller_spec.rb +++ b/spec/controllers/api_v2_application_controller_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -176,7 +176,6 @@ def index end end end - it "responds with error" do get :index @@ -184,6 +183,20 @@ def index 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