From 7fe4dcefb171c088b5ebf987bf647c26227856c0 Mon Sep 17 00:00:00 2001 From: iamsivin Date: Fri, 8 May 2026 13:12:02 +0530 Subject: [PATCH] chore: Clean up --- app/services/data_import/contact_manager.rb | 7 +------ spec/jobs/data_import_job_spec.rb | 7 +++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/services/data_import/contact_manager.rb b/app/services/data_import/contact_manager.rb index 05f4a58da..773efb011 100644 --- a/app/services/data_import/contact_manager.rb +++ b/app/services/data_import/contact_manager.rb @@ -61,14 +61,9 @@ class DataImport::ContactManager def update_contact_attributes(params, contact) contact.name = params[:name] if params[:name].present? contact.additional_attributes ||= {} - assign_additional_attributes(params, contact) - contact.country_code = params[:country] if params[:country].present? - contact.assign_attributes(custom_attributes: contact.custom_attributes.merge(params.except(:identifier, :email, :name, :phone_number))) - end - - def assign_additional_attributes(params, contact) contact.additional_attributes[:company_name] = params[:company_name] if params[:company_name].present? contact.additional_attributes[:city] = params[:city] if params[:city].present? contact.additional_attributes[:country] = params[:country] if params[:country].present? + contact.assign_attributes(custom_attributes: contact.custom_attributes.merge(params.except(:identifier, :email, :name, :phone_number))) end end diff --git a/spec/jobs/data_import_job_spec.rb b/spec/jobs/data_import_job_spec.rb index 31d823da1..11fe1185a 100644 --- a/spec/jobs/data_import_job_spec.rb +++ b/spec/jobs/data_import_job_spec.rb @@ -199,18 +199,17 @@ RSpec.describe DataImportJob do 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 + it 'maps the country column to additional_attributes country' 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') + expect(jane.additional_attributes['country']).to eq('India') bob = Contact.from_email('bob-country@example.com') - expect(bob.country_code).to eq('') + expect(bob.additional_attributes['country']).to be_nil end end