chore: Map country column during CSV import
This commit is contained in:
@@ -188,6 +188,32 @@ RSpec.describe DataImportJob do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the data contains country column' do
|
||||
let(:data_with_country) do
|
||||
[
|
||||
%w[id name email phone_number country],
|
||||
['1', 'John Doe', 'john-country@example.com', '+918080808081', 'United States'],
|
||||
['2', 'Jane Smith', 'jane-country@example.com', '+918080808082', 'India'],
|
||||
['3', 'Bob Wilson', 'bob-country@example.com', '+918080808083', '']
|
||||
]
|
||||
end
|
||||
let(:country_data_import) { create(:data_import, import_file: generate_csv_file(data_with_country)) }
|
||||
|
||||
it 'maps the country column to the standard country_code field' do
|
||||
described_class.perform_now(country_data_import)
|
||||
|
||||
john = Contact.from_email('john-country@example.com')
|
||||
expect(john.country_code).to eq('United States')
|
||||
expect(john.additional_attributes['country']).to eq('United States')
|
||||
|
||||
jane = Contact.from_email('jane-country@example.com')
|
||||
expect(jane.country_code).to eq('India')
|
||||
|
||||
bob = Contact.from_email('bob-country@example.com')
|
||||
expect(bob.country_code).to eq('')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the data contains labels column' do
|
||||
let(:data_with_labels) do
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user