From 6f6ddc5636625ebab43d92d1fd60802234fcb972 Mon Sep 17 00:00:00 2001 From: Aakash Bakhle <48802744+aakashb95@users.noreply.github.com> Date: Wed, 5 Aug 2026 14:07:04 +0530 Subject: [PATCH] fix: flaky AppliedSla scope spec after Rails reloads (#15327) CI no longer fails when the AppliedSla scope spec runs after Rails reloads model classes. The spec now compares record IDs, so it checks which SLA records the scope returns without depending on Ruby class identity. ## How to reproduce Run the report builder and assignment policy controller specs before `spec/enterprise/models/applied_sla_spec.rb` in the same RSpec process. Before the fix, the scope returns records with the expected IDs, but the assertion rejects them because FactoryBot and Rails use different `AppliedSla` class objects after the reload. ## What changed The spec reads the IDs returned by `with_sla_applicable_conversation` and checks the normal conversation, missing contact, and blocked contact cases with those IDs. The affected CircleCI shard passes locally after the change. --- spec/enterprise/models/applied_sla_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/enterprise/models/applied_sla_spec.rb b/spec/enterprise/models/applied_sla_spec.rb index 8b45029ec..bb6712449 100644 --- a/spec/enterprise/models/applied_sla_spec.rb +++ b/spec/enterprise/models/applied_sla_spec.rb @@ -80,8 +80,10 @@ RSpec.describe AppliedSla, type: :model do blocked_applied_sla.conversation.contact.update!(blocked: true) missing_contact_applied_sla.conversation.update_columns(contact_id: nil, contact_inbox_id: nil) # rubocop:disable Rails/SkipsModelValidations - expect(described_class.with_sla_applicable_conversation).to include(applied_sla, missing_contact_applied_sla) - expect(described_class.with_sla_applicable_conversation).not_to include(blocked_applied_sla) + applicable_sla_ids = described_class.with_sla_applicable_conversation.ids + + expect(applicable_sla_ids).to include(applied_sla.id, missing_contact_applied_sla.id) + expect(applicable_sla_ids).not_to include(blocked_applied_sla.id) end end