feat: Add the support for custom attributes in message variables (#8511)

This commit is contained in:
Muhsin Keloth
2023-12-09 03:43:35 +05:30
committed by GitHub
parent bf49a17efa
commit b1a68759cf
4 changed files with 36 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
describe ContactDrop do
subject(:contact_drop) { described_class.new(contact) }
let!(:contact) { create(:contact) }
let!(:contact) { create(:contact, custom_attributes: { car_model: 'Tesla Model S', car_year: '2022' }) }
context 'when first name' do
it 'returns first name' do
@@ -38,4 +38,19 @@ describe ContactDrop do
expect(subject.last_name).to eq 'Doe'
end
end
context 'when accessing custom attributes' do
it 'returns the correct car model from custom attributes' do
expect(contact_drop.custom_attribute['car_model']).to eq 'Tesla Model S'
end
it 'returns the correct car year from custom attributes' do
expect(contact_drop.custom_attribute['car_year']).to eq '2022'
end
it 'returns empty hash when there are no custom attributes' do
contact.update!(custom_attributes: nil)
expect(contact_drop.custom_attribute).to eq({})
end
end
end