From 281372e10d28a6b30903cd74c2b79a487e9f8914 Mon Sep 17 00:00:00 2001 From: Jake Benilov Date: Fri, 18 Oct 2024 13:49:42 +0100 Subject: [PATCH] Add a specific school to seeded teams, if that school exists in the DB This helps anchor automated testing to known data --- db/seeds.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/db/seeds.rb b/db/seeds.rb index 42efafc70..2a479d298 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -68,6 +68,12 @@ def attach_locations_to(team) Location.order("RANDOM()").limit(50).update_all(team_id: team.id) end +def attach_specific_school_to_team_if_present(team:, urn:) + if (school = Location.find_by(urn:)) + school.update!(team_id: team.id) + end +end + def create_session(_user, team) programme = Programme.find_by(type: "hpv") @@ -147,6 +153,8 @@ def create_imports(team) user, team = create_user_and_team(ods_code: "R1L") attach_locations_to(team) +attach_specific_school_to_team_if_present(team:, urn: "136126") # potentially needed for automated testing + Audited.audit_class.as_user(user) { create_session(user, team) } create_patients(team) create_imports(team) @@ -155,6 +163,7 @@ def create_imports(team) user, team = create_user_and_team(ods_code: "Y51", uid: "555057896106") attach_locations_to(team) +attach_specific_school_to_team_if_present(team:, urn: "136126") # potentially needed for automated testing Audited.audit_class.as_user(user) { create_session(user, team) } create_patients(team) create_imports(team)