Skip to content

Commit

Permalink
Update spec to check all policies
Browse files Browse the repository at this point in the history
We want to make sure each policy is covered by this spec to ensure a
claim personal data scrubber is created for any new policies we add.
  • Loading branch information
rjlynch committed Jul 5, 2024
1 parent 8261da5 commit 634024c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions spec/jobs/delete_personal_data_from_old_claims_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
let(:current_academic_year) { AcademicYear.current }
let(:last_academic_year) { Time.zone.local(current_academic_year.start_year, 8, 1) }

it "deletes the personal data from eligible claims" do
submitted_claim = create(:claim, :submitted)
rejected_claim = create(:claim, :submitted)
create(:decision, :rejected, claim: rejected_claim, created_at: last_academic_year)
paid_claim = create(:claim, :approved)
create(:payment, :confirmed, :with_figures, claims: [paid_claim], scheduled_payment_date: last_academic_year)
Policies::POLICIES.each do |policy|
it "deletes the personal data from eligible #{policy} claims" do
submitted_claim = create(:claim, :submitted, policy: policy)
rejected_claim = create(:claim, :submitted, policy: policy)
create(:decision, :rejected, claim: rejected_claim, created_at: last_academic_year)
paid_claim = create(:claim, :approved, policy: policy)
create(:payment, :confirmed, :with_figures, claims: [paid_claim], scheduled_payment_date: last_academic_year)

DeletePersonalDataFromOldClaimsJob.new.perform
DeletePersonalDataFromOldClaimsJob.new.perform

expect(Claim.find(submitted_claim.id).personal_data_removed_at).to be_nil
expect(Claim.find(rejected_claim.id).personal_data_removed_at).to_not be_nil
expect(Claim.find(paid_claim.id).personal_data_removed_at).to_not be_nil
expect(Claim.find(submitted_claim.id).personal_data_removed_at).to be_nil
expect(Claim.find(rejected_claim.id).personal_data_removed_at).to_not be_nil
expect(Claim.find(paid_claim.id).personal_data_removed_at).to_not be_nil
end
end
end
end

0 comments on commit 634024c

Please sign in to comment.