From ab923673bf2392dbe349ac48e9b12379f4c60f3e Mon Sep 17 00:00:00 2001 From: Adam King Date: Thu, 1 Feb 2024 12:35:35 -0600 Subject: [PATCH] Bugfix/15134 set response body (#15287) * 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 | 9 +++++++-- 2 files changed, 11 insertions(+), 2 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 4033b64422d..32d3a9dc75a 100644 --- a/lib/evss/gi_bill_status/gi_bill_status_response.rb +++ b/lib/evss/gi_bill_status/gi_bill_status_response.rb @@ -126,6 +126,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..3080634d30d 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,16 @@ 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') + + expectation = expect do controller.send(:render_error_json, response) end - expect_block.to raise_error(Common::Exceptions::InternalServerError) do |error| + expectation.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