From 5fb282dcbdd693e2155790d0ac5e8ef5b331c543 Mon Sep 17 00:00:00 2001 From: Muhsin Date: Thu, 15 Dec 2022 21:48:08 +0530 Subject: [PATCH] Add specs --- spec/models/message_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb index de237415f..f61e1b57d 100644 --- a/spec/models/message_spec.rb +++ b/spec/models/message_spec.rb @@ -210,4 +210,22 @@ RSpec.describe Message, type: :model do expect(instagram_message.reload.attachments.count).to eq 0 end end + + context 'when message is created with variables' do + let(:contact) { create(:contact, name: 'john', phone_number: '+912883') } + let(:conversation) { create(:conversation, contact: contact) } + let(:message) { build(:message, conversation: conversation) } + + it 'set contact name variable in message' do + message.content = 'hey {{contact.name}} how are you?' + message.save! + expect(message.content).to eq 'hey john how are you?' + end + + it 'set contact phone number variable in message' do + message.content = 'Can we call you at {{contact.phone_number}}?' + message.save! + expect(message.content).to eq 'Can we call you at +912883?' + end + end end