Files
leadchat/spec/jobs/internal/remove_stale_contacts_job_spec.rb
Vishnu Narayanan 0175714d65 feat: add job to remove stale contacts and contact_inboxes (#11186)
- Add a job to remove stale contacts and contact_inboxes across all accounts

Stale anonymous contact is defined as 
- have no identification (email, phone_number, and identifier are NULL)
- have no conversations
- are older than 30 days

---------

Co-authored-by: Pranav <pranav@chatwoot.com>
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
2025-03-28 12:18:39 +05:30

21 lines
624 B
Ruby

require 'rails_helper'
RSpec.describe Internal::RemoveStaleContactsJob do
subject(:job) { described_class.perform_later(account) }
let(:account) { create(:account) }
it 'enqueues the job' do
expect { job }.to have_enqueued_job(described_class)
.with(account)
.on_queue('low')
end
it 'calls the RemoveStaleContactsService' do
service = instance_double(Internal::RemoveStaleContactsService)
expect(Internal::RemoveStaleContactsService).to receive(:new).with(account: account).and_return(service)
expect(service).to receive(:perform)
described_class.perform_now(account)
end
end