chore: Merge contact copy over information (#2812)
fixes: #2767, #2773 Co-authored-by: Nithin David <1277421+nithindavid@users.noreply.github.com>
This commit is contained in:
@@ -4,8 +4,14 @@ describe ::ContactMergeAction do
|
||||
subject(:contact_merge) { described_class.new(account: account, base_contact: base_contact, mergee_contact: mergee_contact).perform }
|
||||
|
||||
let!(:account) { create(:account) }
|
||||
let!(:base_contact) { create(:contact, account: account) }
|
||||
let!(:mergee_contact) { create(:contact, account: account) }
|
||||
let!(:base_contact) do
|
||||
create(:contact, identifier: 'base_contact', email: 'old@old.com', phone_number: '', custom_attributes: { val_test: 'old', val_empty_old: '' },
|
||||
account: account)
|
||||
end
|
||||
let!(:mergee_contact) do
|
||||
create(:contact, identifier: '', email: 'new@new.com', phone_number: '+12212345',
|
||||
custom_attributes: { val_test: 'new', val_new: 'new', val_empty_new: '' }, account: account)
|
||||
end
|
||||
|
||||
before do
|
||||
2.times.each do
|
||||
@@ -21,6 +27,18 @@ describe ::ContactMergeAction do
|
||||
expect { mergee_contact.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
it 'copies information from mergee contact to base contact' do
|
||||
contact_merge
|
||||
base_contact.reload
|
||||
expect(base_contact.identifier).to eq('base_contact')
|
||||
expect(base_contact.email).to eq('old@old.com')
|
||||
expect(base_contact.phone_number).to eq('+12212345')
|
||||
expect(base_contact.custom_attributes['val_test']).to eq('old')
|
||||
expect(base_contact.custom_attributes['val_new']).to eq('new')
|
||||
expect(base_contact.custom_attributes['val_empty_old']).to eq('')
|
||||
expect(base_contact.custom_attributes['val_empty_new']).to eq('')
|
||||
end
|
||||
|
||||
context 'when base contact and merge contact are same' do
|
||||
it 'does not delete contact' do
|
||||
mergee_contact = base_contact
|
||||
|
||||
Reference in New Issue
Block a user