From b2f4f26f3e4182191e7681a672a281200b60c8bb Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 2 Mar 2026 10:45:26 +0000 Subject: [PATCH] Fix flaky tests by making school teacher ID lookup deterministic Example failure - https://github.com/RaspberryPiFoundation/editor-api/actions/runs/22571941511/job/65381726124 This was making the order that teaches returned non-deterministic, which was causing intermittent test failures. The test that was failing was the 'SchoolTeacher::List when successful when not passing teacher_ids returns a successful response with school teachers' test in ./spec/concepts/school_teacher/list_spec.rb. Co-authored-by: Chris Zetter --- lib/concepts/school_teacher/list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/concepts/school_teacher/list.rb b/lib/concepts/school_teacher/list.rb index 69466c33f..792174338 100644 --- a/lib/concepts/school_teacher/list.rb +++ b/lib/concepts/school_teacher/list.rb @@ -5,7 +5,7 @@ class List class << self def call(school:, teacher_ids: nil) response = OperationResponse.new - teacher_ids = school.roles.where(role: :teacher)&.pluck(:user_id) if teacher_ids.blank? + teacher_ids = school.roles.where(role: :teacher).order(:id).pluck(:user_id) if teacher_ids.blank? response[:school_teachers] = list_teachers(teacher_ids) response rescue StandardError => e