From b42070c73503c52619048182463977eb80eef084 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Wed, 30 Oct 2024 13:26:45 +0000 Subject: [PATCH] Run claim verifiers for policy if it has them Previously we were not running the claim verifiers for EY as EY claims don't have a trn. This commit passes in a nil dqt teacher status if the policy doesn't have a trn but still runs the claim verifiers. --- app/jobs/claim_verifier_job.rb | 20 ++++++++++++-------- spec/jobs/claim_verifier_job_spec.rb | 10 ++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/jobs/claim_verifier_job.rb b/app/jobs/claim_verifier_job.rb index f149cce24a..64b93cea86 100644 --- a/app/jobs/claim_verifier_job.rb +++ b/app/jobs/claim_verifier_job.rb @@ -1,8 +1,17 @@ class ClaimVerifierJob < ApplicationJob def perform(claim) - dqt_teacher_status = if claim.policy == Policies::EarlyYearsPayments - nil - elsif claim.has_dqt_record? + AutomatedChecks::ClaimVerifier.new( + claim: claim, + dqt_teacher_status: dqt_teacher_status(claim) + ).perform + end + + private + + def dqt_teacher_status(claim) + return if claim.policy == Policies::EarlyYearsPayments + + if claim.has_dqt_record? Dqt::Teacher.new(claim.dqt_teacher_status) else Dqt::Client.new.teacher.find( @@ -11,10 +20,5 @@ def perform(claim) nino: claim.national_insurance_number ) end - - AutomatedChecks::ClaimVerifier.new( - claim:, - dqt_teacher_status: - ).perform end end diff --git a/spec/jobs/claim_verifier_job_spec.rb b/spec/jobs/claim_verifier_job_spec.rb index 46163c322a..311a76d91d 100644 --- a/spec/jobs/claim_verifier_job_spec.rb +++ b/spec/jobs/claim_verifier_job_spec.rb @@ -40,6 +40,16 @@ end end + context "when the claim is for EarlyYearsPayments" do + let(:claim) { build(:claim, policy: Policies::EarlyYearsPayments) } + + it "performs the verifier job but doesn't request dqt info" do + expect(AutomatedChecks::ClaimVerifier).to receive(:new) + expect(dbl).not_to receive(:find) + described_class.new.perform(claim) + end + end + context "when the claim does not have a DQT record payload" do let(:dqt_teacher_status) { nil }