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 }