From 073fd3746549f8fc6cdeb49f23ba0d610805177f Mon Sep 17 00:00:00 2001 From: Jamie Benstead Date: Fri, 13 Feb 2026 13:30:35 +0000 Subject: [PATCH] Add jim dun seed data --- lib/tasks/seeds_helper.rb | 3 ++- lib/tasks/test_seeds.rake | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/tasks/seeds_helper.rb b/lib/tasks/seeds_helper.rb index b73a8d3f5..4b86617c0 100644 --- a/lib/tasks/seeds_helper.rb +++ b/lib/tasks/seeds_helper.rb @@ -6,7 +6,8 @@ module SeedsHelper john_doe: 'bbb9b8fd-f357-4238-983d-6f87b99bdbb2', # john.doe@example.com jane_smith: 'e52de409-9210-4e94-b08c-dd11439e07d9', # student john_smith: '0d488bec-b10d-46d3-b6f3-4cddf5d90c71', # student - emily_ssouser: '88e0aed6-8f20-4e40-98f9-610a0ab1cfcc' # sso student + emily_ssouser: '88e0aed6-8f20-4e40-98f9-610a0ab1cfcc', # sso student + jim_dun: '019a649f-87f3-483b-8eea-39a05c324264' # user with no school }.freeze # Match the school in profile... diff --git a/lib/tasks/test_seeds.rake b/lib/tasks/test_seeds.rake index 3b57495d5..6b2e45832 100644 --- a/lib/tasks/test_seeds.rake +++ b/lib/tasks/test_seeds.rake @@ -12,26 +12,32 @@ namespace :test_seeds do Rails.logger.info 'Destroying existing seeds...' creator_id = ENV.fetch('SEEDING_CREATOR_ID', TEST_USERS[:jane_doe]) teacher_id = ENV.fetch('SEEDING_TEACHER_ID', TEST_USERS[:john_doe]) + teacher_signup_id = TEST_USERS[:jim_dun] # Hard coded as the student's school needs to match student_ids = [TEST_USERS[:jane_smith], TEST_USERS[:john_smith], TEST_USERS[:emily_ssouser]] school_id = TEST_SCHOOL + teacher_signup_school_id = + School.find_by(creator_id: teacher_signup_id)&.id # Remove the roles first + Role.where(user_id: teacher_signup_id).destroy_all Role.where(user_id: [creator_id, teacher_id] + student_ids).destroy_all # Destroy the project and then the lesson itself (The lesson's `before_destroy` prevents us using destroy) lesson_ids = Lesson.where(school_id:).pluck(:id) - Project.where(lesson_id: [lesson_ids]).destroy_all - Lesson.where(id: [lesson_ids]).delete_all + Project.where(lesson_id: lesson_ids).destroy_all + Lesson.where(id: lesson_ids).delete_all # Destroy the class members and then the class itself school_class_ids = SchoolClass.where(school_id:).pluck(:id) - ClassStudent.where(school_class_id: [school_class_ids]).destroy_all - SchoolClass.where(id: [school_class_ids]).destroy_all + ClassStudent.where(school_class_id: school_class_ids).destroy_all + SchoolClass.where(id: school_class_ids).destroy_all - # Destroy the school - School.find(school_id).destroy + # Destroy the schools + # school_ids = [school_id, teacher_signup_school_id].compact + School.where(id: school_id).destroy_all + School.where(id: teacher_signup_school_id).destroy_all Rails.logger.info 'Done...' rescue StandardError => e