Skip to content

Commit 63041e5

Browse files
committed
Ensure all school move attributes are reset
This fixes an issue where if a patient already had a school move, when we set the `school`, we don't clear our the `team_id` and `home_educated` columns, leading to a validation error. I thought about adding tests for this, but this code is being removed in a follow up PR (#6373) so I thought it was fine to leave it without. There has been a Sentry issue raised for this, so we can check to see that those stop. Sentry-Issue: 7361583189
1 parent 5096c0f commit 63041e5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

app/models/patient_changeset.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,12 @@ def school_move
290290
school_move =
291291
patient.school_moves.includes(:school_teams).first ||
292292
SchoolMove.new(patient:)
293+
294+
# TODO: Simplify this once we no longer have changesets with
295+
# `school_id` set to `nil`.
293296
school_move.assign_attributes(
294-
# TODO: Simplify this once we no longer have changesets with
295-
# `school_id` set to `nil`.
297+
academic_year:,
298+
home_educated: nil,
296299
school:
297300
school ||
298301
(
@@ -302,9 +305,10 @@ def school_move
302305
team.unknown_school
303306
end
304307
),
305-
academic_year:,
308+
team_id: nil,
306309
source: school_move_source
307310
)
311+
308312
# TODO: Figure out why this is necessary.
309313
school_move.strict_loading!(false)
310314
school_move

0 commit comments

Comments
 (0)