Files
leadchat/spec/services/contacts/bulk_delete_service_spec.rb
Sojan Jose f89d9a4401 feat: Bulk delete for contacts (#12778)
Introduces a new bulk action `delete` for contacts

ref: https://github.com/chatwoot/chatwoot/pull/12763

## Screens

<img width="1492" height="973" alt="Screenshot 2025-10-31 at 6 27 21 PM"
src="https://github.com/user-attachments/assets/30dab1bb-2c2c-4168-9800-44e0eb5f8e3a"
/>
<img width="1492" height="985" alt="Screenshot 2025-10-31 at 6 27 32 PM"
src="https://github.com/user-attachments/assets/5be610c4-b19e-4614-a164-103b22337382"
/>
2025-11-04 17:47:53 -08:00

25 lines
873 B
Ruby

require 'rails_helper'
RSpec.describe Contacts::BulkDeleteService do
subject(:service) { described_class.new(account: account, contact_ids: contact_ids) }
let(:account) { create(:account) }
let!(:contact_one) { create(:contact, account: account) }
let!(:contact_two) { create(:contact, account: account) }
let(:contact_ids) { [contact_one.id, contact_two.id] }
describe '#perform' do
it 'deletes the provided contacts' do
expect { service.perform }
.to change { account.contacts.exists?(contact_one.id) }.from(true).to(false)
.and change { account.contacts.exists?(contact_two.id) }.from(true).to(false)
end
it 'returns when no contact ids are provided' do
empty_service = described_class.new(account: account, contact_ids: [])
expect { empty_service.perform }.not_to change(Contact, :count)
end
end
end