-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract policy specific claim data scrubber
Different policies will have different rules around what data we need to retain. This commit adds policy specific subclasses for handling removing personal data. Subclasses can implement policy specific behaviour by redefining the PERSONAL_DATA_ATTRIBUTES_TO_DELETE constant or overwriting the `scrub_completed_claims` method.
- Loading branch information
Showing
21 changed files
with
193 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/models/policies/early_career_payments/claim_personal_data_scrubber.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Policies | ||
module EarlyCareerPayments | ||
class ClaimPersonalDataScrubber < Claim::PersonalDataScrubber | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/models/policies/further_education_payments/claim_personal_data_scrubber.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Policies | ||
module FurtherEducationPayments | ||
class ClaimPersonalDataScrubber < Claim::PersonalDataScrubber | ||
def scrub_completed_claims | ||
# FIXME RL: temp NOOP until business decsion around whether TRN is | ||
# required in the payment claim matching has been resolved | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
app/models/policies/international_relocation_payments/claim_personal_data_scrubber.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Policies | ||
module InternationalRelocationPayments | ||
class ClaimPersonalDataScrubber < Claim::PersonalDataScrubber | ||
def scrub_completed_claims | ||
# FIXME RL: temp NOOP until business decsion around whether TRN is | ||
# required in the payment claim matching has been resolved | ||
end | ||
end | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
app/models/policies/levelling_up_premium_payments/claim_personal_data_scrubber.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Policies | ||
module LevellingUpPremiumPayments | ||
class ClaimPersonalDataScrubber < Claim::PersonalDataScrubber | ||
end | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
app/models/policies/student_loans/claim_personal_data_scrubber.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Policies | ||
module StudentLoans | ||
class ClaimPersonalDataScrubber < Claim::PersonalDataScrubber | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...ate/20240701143154_add_award_amount_to_international_relocation_payments_eligibilities.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddAwardAmountToInternationalRelocationPaymentsEligibilities < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :international_relocation_payments_eligibilities, :award_amount, :decimal, precision: 7, scale: 2 | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20240702105328_add_award_amount_to_further_education_payments_eligibilities.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddAwardAmountToFurtherEducationPaymentsEligibilities < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :further_education_payments_eligibilities, :award_amount, :decimal, precision: 7, scale: 2 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
spec/factories/policies/further_education_payments/eligibilities.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryBot.define do | ||
factory :further_education_payments_eligibility, class: "Policies::FurtherEducationPayments::Eligibility" do | ||
trait :eligible do | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
spec/models/policies/early_career_payments/claim_personal_data_scrubber_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Policies::EarlyCareerPayments::ClaimPersonalDataScrubber do | ||
it_behaves_like( | ||
"a claim personal data scrubber", | ||
Policies::EarlyCareerPayments | ||
) | ||
end |
10 changes: 10 additions & 0 deletions
10
spec/models/policies/further_education_payments/claim_personal_data_scrubber_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Policies::FurtherEducationPayments::ClaimPersonalDataScrubber do | ||
# FIXME RL: temp disabled until business decsion around whether TRN is | ||
# required in the payment claim matching has been resolved | ||
# it_behaves_like( | ||
# "a claim personal data scrubber", | ||
# Policies::FurtherEducationPayments | ||
# ) | ||
end |
10 changes: 10 additions & 0 deletions
10
spec/models/policies/international_relocation_payments/claim_personal_data_scrubber_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Policies::InternationalRelocationPayments::ClaimPersonalDataScrubber do | ||
# FIXME RL: temp disabled until business decsion around whether TRN is | ||
# required in the payment claim matching has been resolved | ||
# it_behaves_like( | ||
# "a claim personal data scrubber", | ||
# Policies::InternationalRelocationPayments | ||
# ) | ||
end |
40 changes: 40 additions & 0 deletions
40
spec/models/policies/levelling_up_premium_payments/claim_personal_data_scrubber_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Policies::LevellingUpPremiumPayments::ClaimPersonalDataScrubber do | ||
it_behaves_like( | ||
"a claim personal data scrubber", | ||
Policies::LevellingUpPremiumPayments | ||
) | ||
|
||
subject(:personal_data_scrubber) { described_class.new.scrub_completed_claims } | ||
let!(:journey_configuration) { create(:journey_configuration, :additional_payments) } | ||
let(:current_academic_year) { AcademicYear.current } | ||
let(:last_academic_year) { Time.zone.local(current_academic_year.start_year, 8, 1) } | ||
let(:user) { create(:dfe_signin_user) } | ||
|
||
it "does not delete details from a claim that has a payment, but has a payrollable topup" do | ||
eligibility = create(:levelling_up_premium_payments_eligibility, :eligible, award_amount: 1500.0) | ||
|
||
claim = create(:claim, :approved, policy: Policies::LevellingUpPremiumPayments, eligibility: eligibility) | ||
|
||
create(:payment, :confirmed, :with_figures, claims: [claim], scheduled_payment_date: last_academic_year) | ||
create(:topup, payment: nil, claim: claim, award_amount: 500, created_by: user) | ||
|
||
expect { personal_data_scrubber }.not_to change { claim.reload.attributes } | ||
end | ||
|
||
it "does not delete details from a claim that has a payment, but has a payrolled topup without payment confirmation" do | ||
claim = nil | ||
|
||
travel_to 2.months.ago do | ||
eligibility = create(:levelling_up_premium_payments_eligibility, :eligible, award_amount: 1500.0) | ||
claim = create(:claim, :approved, policy: Policies::LevellingUpPremiumPayments, eligibility: eligibility) | ||
create(:payment, :confirmed, :with_figures, claims: [claim], scheduled_payment_date: last_academic_year) | ||
end | ||
|
||
payment2 = create(:payment, :with_figures, claims: [claim], scheduled_payment_date: nil) | ||
create(:topup, payment: payment2, claim: claim, award_amount: 500, created_by: user) | ||
|
||
expect { personal_data_scrubber }.not_to change { claim.reload.attributes } | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
spec/models/policies/student_loans/claim_personal_data_scrubber_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Policies::StudentLoans::ClaimPersonalDataScrubber do | ||
it_behaves_like( | ||
"a claim personal data scrubber", | ||
Policies::StudentLoans | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters