From e5dd3793baae93dacb4135ff0f4194f902264c3c Mon Sep 17 00:00:00 2001 From: Adam King Date: Tue, 16 Jan 2024 17:08:38 -0600 Subject: [PATCH] https://github.com/department-of-veterans-affairs/vets-api/issues/15134 See https://github.com/department-of-veterans-affairs/vets-api/pull/15075 and https://github.com/department-of-veterans-affairs/va.gov-team/issues/65182 for the Original PR and Github Issue, respectively. This PR exposes a `body` attribute on the `GiBillStatusResponse` object, so it can be logged out as intended in the original PR. --- lib/evss/gi_bill_status/gi_bill_status_response.rb | 4 ++++ .../v0/post911_gi_bill_statuses_controller_spec.rb | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/evss/gi_bill_status/gi_bill_status_response.rb b/lib/evss/gi_bill_status/gi_bill_status_response.rb index 8b5487671db..70b904c175c 100644 --- a/lib/evss/gi_bill_status/gi_bill_status_response.rb +++ b/lib/evss/gi_bill_status/gi_bill_status_response.rb @@ -113,6 +113,10 @@ def error_type 'unknown' end + def body + @response.body + end + private def timeout? diff --git a/spec/controllers/v0/post911_gi_bill_statuses_controller_spec.rb b/spec/controllers/v0/post911_gi_bill_statuses_controller_spec.rb index a8b67d8c2ff..7641f9f356b 100644 --- a/spec/controllers/v0/post911_gi_bill_statuses_controller_spec.rb +++ b/spec/controllers/v0/post911_gi_bill_statuses_controller_spec.rb @@ -136,11 +136,14 @@ end it 'raises an InternalServerError including an exception with a detailed message' do - expect_block = expect do + response = instance_double("EVSS::GiBillStatus::GiBillStatusResponse") + allow(response).to receive(:error_type).and_return("unknown") + allow(response).to receive(:status).and_return(500) + allow(response).to receive(:body).and_return("Unknown error") + + expect do controller.send(:render_error_json, response) - end - - expect_block.to raise_error(Common::Exceptions::InternalServerError) do |error| + end.to raise_error(Common::Exceptions::InternalServerError) do |error| expected_msg = 'An unknown error occurred. Response error type: unknown, status: 500, body: Unknown error' expect(error.exception.message).to eq(expected_msg) end