From a5cbc9404810313d4303e55da341526222dbfd97 Mon Sep 17 00:00:00 2001 From: Gregory Hedrick Date: Thu, 20 Feb 2025 10:08:42 -0500 Subject: [PATCH] Troubleshoot testing --- .../power_of_attorney_requests_controller.rb | 2 +- .../factories/power_of_attorney_request.rb | 17 +++++++++++++ .../v0/power_of_attorney_requests_spec.rb | 24 +++++++++++++------ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/power_of_attorney_requests_controller.rb b/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/power_of_attorney_requests_controller.rb index 2e333f31ed3..bed3f0ecdb9 100644 --- a/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/power_of_attorney_requests_controller.rb +++ b/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/power_of_attorney_requests_controller.rb @@ -32,7 +32,7 @@ def index when Statuses::PENDING pending(relation) when Statuses::PROCESSED - processing(relation) + processed(relation) when NilClass relation else diff --git a/modules/accredited_representative_portal/spec/factories/power_of_attorney_request.rb b/modules/accredited_representative_portal/spec/factories/power_of_attorney_request.rb index ac440ba076f..53d6f778ee4 100644 --- a/modules/accredited_representative_portal/spec/factories/power_of_attorney_request.rb +++ b/modules/accredited_representative_portal/spec/factories/power_of_attorney_request.rb @@ -33,6 +33,23 @@ end end + trait :with_form_submission do + after(:build) do |poa_request, _evaluator| + poa_request.power_of_attorney_form_submission = build(:power_of_attorney_form_submission, + power_of_attorney_request: poa_request) + end + end + + trait :with_failed_form_submission do + after(:build) do |poa_request, _evaluator| + poa_request.power_of_attorney_form_submission = build( + :power_of_attorney_form_submission, + power_of_attorney_request: poa_request, + status: :failed + ) + end + end + trait :with_declination do after(:build) do |poa_request, evaluator| poa_request.resolution = build( diff --git a/modules/accredited_representative_portal/spec/requests/accredited_representative_portal/v0/power_of_attorney_requests_spec.rb b/modules/accredited_representative_portal/spec/requests/accredited_representative_portal/v0/power_of_attorney_requests_spec.rb index 5c5a8ad7fc5..8fa7e238305 100644 --- a/modules/accredited_representative_portal/spec/requests/accredited_representative_portal/v0/power_of_attorney_requests_spec.rb +++ b/modules/accredited_representative_portal/spec/requests/accredited_representative_portal/v0/power_of_attorney_requests_spec.rb @@ -124,7 +124,7 @@ def load_response_fixture(path_suffix) 'id' => poa_requests[1].accredited_organization.poa }, 'powerOfAttorneyFormSubmission' => { - 'status' => 'FAILED' + 'status' => 'pending' } }, { @@ -182,9 +182,17 @@ def load_response_fixture(path_suffix) let!(:pending_request1) { create(:power_of_attorney_request, created_at: time) } let!(:pending_request2) { create(:power_of_attorney_request, created_at: time_plus_one_day) } let!(:declined_request) { create(:power_of_attorney_request, :with_declination, resolution_created_at: time) } - let!(:accepted_request) do + let!(:accepted_pending_request) do create(:power_of_attorney_request, :with_acceptance, resolution_created_at: time_plus_one_day) end + let!(:accepted_failed_request) do + create(:power_of_attorney_request, :with_acceptance, :with_failed_form_submission, + resolution_created_at: time_plus_one_day) + end + let!(:accepted_success_request) do + create(:power_of_attorney_request, :with_acceptance, :with_form_submission, + resolution_created_at: time_plus_one_day) + end let!(:expired_request) do create(:power_of_attorney_request, :with_expiration, resolution_created_at: time_plus_one_day) end @@ -193,9 +201,11 @@ def load_response_fixture(path_suffix) get('/accredited_representative_portal/v0/power_of_attorney_requests?status=pending') parsed_response = JSON.parse(response.body) expect(response).to have_http_status(:ok) - expect(parsed_response.length).to eq 2 - expect(parsed_response.map { |poa| poa['id'] }).not_to include(declined_request.id) - expect(parsed_response.map { |poa| poa['id'] }).not_to include(accepted_request.id) + expect(parsed_response.length).to eq 4 + expect(parsed_response.map { |poa| poa['id'] }).to include(pending_request1.id) + expect(parsed_response.map { |poa| poa['id'] }).to include(pending_request2.id) + expect(parsed_response.map { |poa| poa['id'] }).to include(accepted_pending_request.id) + expect(parsed_response.map { |poa| poa['id'] }).to include(accepted_failed_request.id) expect(parsed_response.map { |poa| poa['id'] }).not_to include(expired_request.id) expect(parsed_response.map { |h| h['createdAt'] }).to eq([time, time_plus_one_day]) end @@ -205,8 +215,8 @@ def load_response_fixture(path_suffix) parsed_response = JSON.parse(response.body) expect(response).to have_http_status(:ok) expect(parsed_response.length).to eq 2 - expect(parsed_response.map { |poa| poa['id'] }).not_to include(pending_request1.id) - expect(parsed_response.map { |poa| poa['id'] }).not_to include(pending_request2.id) + expect(parsed_response.map { |poa| poa['id'] }).to include(declined_request.id) + expect(parsed_response.map { |poa| poa['id'] }).to include(accepted_success_request.id) expect(parsed_response.map { |poa| poa['id'] }).not_to include(expired_request.id) expect(parsed_response.map { |h| h['resolution']['createdAt'] }).to eq([time_plus_one_day, time]) end