Skip to content

Commit

Permalink
Troubleshoot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pixiitech committed Feb 20, 2025
1 parent 9ec71ce commit 4f8d13a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def index
when Statuses::PENDING
pending(relation)
when Statuses::PROCESSED
processing(relation)
processed(relation)
when NilClass
relation
else
Expand Down Expand Up @@ -63,9 +63,9 @@ def pending(relation)
end

def processed(relation)
relation
.processed.where.not(resolution: { resolving_type: PowerOfAttorneyRequestExpiration })
.order(resolution: { created_at: :desc })
relation.processed.where.not(
resolution: { resolving_type: PowerOfAttorneyRequestExpiration.to_s }
).order(resolution: { created_at: :desc })
end

def scope_includes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def load_response_fixture(path_suffix)
'id' => poa_requests[1].accredited_organization.poa
},
'powerOfAttorneyFormSubmission' => {
'status' => 'FAILED'
'status' => 'pending'
}
},
{
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4f8d13a

Please sign in to comment.