fix: Handle Contact import MalformedCSVError (#8706)

This commit is contained in:
Muhsin Keloth
2024-01-18 13:05:58 +05:30
committed by GitHub
parent eb972684b3
commit c899cc825d
4 changed files with 42 additions and 2 deletions

View File

@@ -151,5 +151,20 @@ RSpec.describe DataImportJob do
end
end
end
context 'when the CSV file is invalid' do
let(:invalid_csv_content) do
"id,name,email,phone_number,company\n1,\"Clarice Uzzell,\"missing_quote,918080808080,Acmecorp\n2,Marieann Creegan,,+918080808081,Acmecorp"
end
before do
allow(data_import.import_file).to receive(:download).and_return(invalid_csv_content)
end
it 'does not import any data and handles the MalformedCSVError' do
expect { described_class.perform_now(data_import) }
.to change { data_import.reload.status }.from('pending').to('failed')
end
end
end
end