fix: isolate race condition test by filtering jobs for specific conversation

The test was checking total ConversationReplyEmailWorker.jobs.size which accumulates
across the entire test suite in CI, causing false failures. Now filters jobs by
conversation_id to only count workers for the specific conversation under test.
This commit is contained in:
Shivam Mishra
2025-10-15 14:28:08 +05:30
parent 3bb95a8892
commit 91a279136a

View File

@@ -74,7 +74,8 @@ describe Messages::SendEmailNotificationService do
threads.each(&:join)
# Only ONE worker should be scheduled despite 5 concurrent attempts
expect(ConversationReplyEmailWorker.jobs.size).to eq(1)
jobs_for_conversation = ConversationReplyEmailWorker.jobs.select { |job| job['args'].first == conversation.id }
expect(jobs_for_conversation.size).to eq(1)
end
end