diff --git a/app/models/message.rb b/app/models/message.rb index 37c1c39b5..bf9593635 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -149,7 +149,7 @@ class Message < ApplicationRecord end def process_liquid_in_content - return if content.blank? + return if content.blank? || message_type != 'outgoing' template = Liquid::Template.parse(content) diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb index 61f8744d5..b51fbda6f 100644 --- a/spec/models/message_spec.rb +++ b/spec/models/message_spec.rb @@ -214,7 +214,7 @@ RSpec.describe Message, type: :model do context 'when message is created with variables' do let(:contact) { create(:contact, name: 'john', phone_number: '+912883') } let(:conversation) { create(:conversation, id: 1, contact: contact) } - let(:message) { build(:message, conversation: conversation) } + let(:message) { build(:message, conversation: conversation, message_type: 'outgoing') } it 'set contact name variable in message' do message.content = 'hey {{contact.name}} how are you?'