From 94892e71687fab7d21843e892dac05e45ded3ee5 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Sat, 17 Feb 2024 01:41:39 +0530 Subject: [PATCH] chore: Fix flaky spec relying on unguaranteed order (#8956) --- .../api/v1/accounts/contacts_controller_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/controllers/api/v1/accounts/contacts_controller_spec.rb b/spec/controllers/api/v1/accounts/contacts_controller_spec.rb index ace9e8e03054..e5e298747535 100644 --- a/spec/controllers/api/v1/accounts/contacts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/contacts_controller_spec.rb @@ -50,8 +50,11 @@ expect(response).to have_http_status(:success) response_body = response.parsed_body - expect(response_body['payload'].first['email']).to eq(contact.email) - expect(response_body['payload'].first['contact_inboxes'].blank?).to be(true) + + contact_emails = response_body['payload'].pluck('email') + contact_inboxes = response_body['payload'].pluck('contact_inboxes').flatten.compact + expect(contact_emails).to include(contact.email) + expect(contact_inboxes).to eq([]) end it 'returns all contacts with company name desc order' do