From f732e2a88d29984d46aa6b1f416c237df8c36011 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Wed, 9 Oct 2024 14:24:10 +0100 Subject: [PATCH] back office can filter for auto approved claims --- app/forms/admin/claims_filter_form.rb | 3 +++ spec/factories/claims.rb | 4 ++++ spec/forms/admin/claims_filter_form_spec.rb | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/app/forms/admin/claims_filter_form.rb b/app/forms/admin/claims_filter_form.rb index c80a57b1fe..0b4ac548c6 100644 --- a/app/forms/admin/claims_filter_form.rb +++ b/app/forms/admin/claims_filter_form.rb @@ -48,6 +48,8 @@ def claims Claim.approved.awaiting_qa when "approved_awaiting_payroll" approved_awaiting_payroll + when "automatically_approved" + Claim.current_academic_year.auto_approved when "automatically_approved_awaiting_payroll" Claim.current_academic_year.payrollable.auto_approved when "rejected" @@ -94,6 +96,7 @@ def status_select_options ["Awaiting decision - failed bank details", "failed_bank_validation"], ["Approved awaiting QA", "approved_awaiting_qa"], ["Approved awaiting payroll", "approved_awaiting_payroll"], + ["Automatically approved", "automatically_approved"], ["Automatically approved awaiting payroll", "automatically_approved_awaiting_payroll"], ["Approved", "approved"], ["Rejected", "rejected"] diff --git a/spec/factories/claims.rb b/spec/factories/claims.rb index 0680f2c5bb..f83470ca17 100644 --- a/spec/factories/claims.rb +++ b/spec/factories/claims.rb @@ -41,6 +41,10 @@ claim.academic_year = claim_academic_year unless claim.academic_year_before_type_cast end + trait :current_academic_year do + academic_year { AcademicYear.current } + end + trait :with_onelogin_idv_data do identity_confirmed_with_onelogin { true } onelogin_uid { SecureRandom.uuid } diff --git a/spec/forms/admin/claims_filter_form_spec.rb b/spec/forms/admin/claims_filter_form_spec.rb index 5364b7f2b2..8edf7a8473 100644 --- a/spec/forms/admin/claims_filter_form_spec.rb +++ b/spec/forms/admin/claims_filter_form_spec.rb @@ -80,5 +80,21 @@ ) end end + + context "filtering for unassigned + auto approved claims" do + subject { described_class.new(session:, filters: {team_member:, status:}) } + + let(:team_member) { "unassigned" } + let(:status) { "automatically_approved" } + let(:session) { {} } + + before do + create(:claim, :submitted, :auto_approved, :current_academic_year) + end + + it "works" do + expect(subject.claims.count).to eql(1) + end + end end end