From 9ea20feaed45c12a424ef8efcb4443f102cf2f23 Mon Sep 17 00:00:00 2001 From: Clay Sheppard Date: Thu, 7 Sep 2023 11:49:49 -0500 Subject: [PATCH] APPEALS-24121 - Fix flaky/skipped tests in feature/api/v2/appeals_spec.rb (#19318) * change spec to match current functionality * add context and revert expectation * change api view count to 0 --- spec/feature/api/v2/appeals_spec.rb | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/spec/feature/api/v2/appeals_spec.rb b/spec/feature/api/v2/appeals_spec.rb index 844162bedcf..c305a63237a 100644 --- a/spec/feature/api/v2/appeals_spec.rb +++ b/spec/feature/api/v2/appeals_spec.rb @@ -66,21 +66,28 @@ expect(ApiView.count).to eq(0) end - it "returns 404 if veteran with that SSN isn't found", skip: "I believe this just returns an empty array" do - headers = { - "ssn": "444444444", - "Authorization": "Token token=#{api_key.key_string}" - } + context "ssn not found" do + before do + allow_any_instance_of(Fakes::BGSService).to receive(:fetch_file_number_by_ssn) do |_bgs, _ssn| + nil + end + end - get "/api/v2/appeals", headers: headers + it "returns 404 if veteran with that SSN isn't found" do + headers = { + "ssn": "444444444", + "Authorization": "Token token=#{api_key.key_string}" + } - expect(response.code).to eq("404") + get "/api/v2/appeals", headers: headers - json = JSON.parse(response.body) - expect(json["errors"].length).to eq(1) - expect(json["errors"].first["title"]).to eq("Veteran not found") + expect(response.code).to eq("404") - expect(ApiView.count).to eq(1) + json = JSON.parse(response.body) + expect(json["errors"].length).to eq(1) + expect(json["errors"].first["title"]).to eq("Veteran not found") + expect(ApiView.count).to eq(0) + end end it "records source if sent" do