chore: Contact import improvements (#7787)

- Ensure existing contact information is updated on data import
- Refactor the existing job to make it more readable
- Fixes issues with import files in the wrong encoding
fixes: #7307
This commit is contained in:
Sojan Jose
2023-08-23 23:24:47 -07:00
committed by GitHub
parent 44f6a9ec3c
commit acb7debd3f
11 changed files with 174 additions and 100 deletions

View File

@@ -57,6 +57,24 @@ RSpec.describe AdministratorNotifications::ChannelNotificationsMailer do
end
end
describe 'contact_import_complete' do
let!(:data_import) { build(:data_import, total_records: 10, processed_records: 10) }
let(:mail) { described_class.with(account: account).contact_import_complete(data_import).deliver_now }
it 'renders the subject' do
expect(mail.subject).to eq('Contact Import Completed')
end
it 'renders the processed records' do
expect(mail.body.encoded).to match('Number of records imported: 10')
expect(mail.body.encoded).to match('Number of records failed: 0')
end
it 'renders the receiver email' do
expect(mail.to).to eq([administrator.email])
end
end
describe 'contact_export_complete' do
let!(:file_url) { Rails.application.routes.url_helpers.rails_blob_url(account.contacts_export) }
let(:mail) { described_class.with(account: account).contact_export_complete(file_url).deliver_now }