Skip to content

Commit

Permalink
Only normalise attributes if present
Browse files Browse the repository at this point in the history
This lets us call save when scrubbing attributes, rather than using
`update_columns` which bypasses dfe analytics
  • Loading branch information
rjlynch committed Aug 1, 2024
1 parent 86705f2 commit f96cb79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ class Claim < ApplicationRecord
validate :building_society_roll_number_must_be_between_one_and_eighteen_digits
validate :building_society_roll_number_must_be_in_a_valid_format

before_save :normalise_ni_number, if: :national_insurance_number_changed?
before_save :normalise_bank_account_number, if: :bank_account_number_changed?
before_save :normalise_bank_sort_code, if: :bank_sort_code_changed?
before_save :normalise_first_name, if: :first_name_changed?
before_save :normalise_surname, if: :surname_changed?
before_save :normalise_ni_number, if: %i[national_insurance_number national_insurance_number_changed?]
before_save :normalise_bank_account_number, if: %i[bank_account_number bank_account_number_changed?]
before_save :normalise_bank_sort_code, if: %i[bank_sort_code bank_sort_code_changed?]
before_save :normalise_first_name, if: %i[first_name first_name_changed?]
before_save :normalise_surname, if: %i[surname surname_changed?]

scope :unsubmitted, -> { where(submitted_at: nil) }
scope :submitted, -> { where.not(submitted_at: nil) }
Expand Down
2 changes: 1 addition & 1 deletion app/models/claim/scrubber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def scrub_claim!
attributes_to_set = personal_data_mask.merge(
personal_data_removed_at: Time.zone.now
)
claim.update_columns(attributes_to_set)
claim.update!(attributes_to_set)
end

def scrub_session!
Expand Down

0 comments on commit f96cb79

Please sign in to comment.