fix: mention notification mail for empty contact name (#5091)
This commit is contained in:
parent
8acba37baf
commit
ffec427513
2 changed files with 15 additions and 1 deletions
|
@ -6,7 +6,7 @@ class ConversationDrop < BaseDrop
|
|||
end
|
||||
|
||||
def contact_name
|
||||
@obj.try(:contact).name.capitalize || 'Customer'
|
||||
@obj.try(:contact).name.try(:capitalize) || 'Customer'
|
||||
end
|
||||
|
||||
def recent_messages
|
||||
|
|
|
@ -39,9 +39,17 @@ RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :maile
|
|||
end
|
||||
|
||||
describe 'conversation_mention' do
|
||||
let(:contact) { create(:contact, name: nil, account: account) }
|
||||
let(:another_agent) { create(:user, email: 'agent2@example.com', account: account) }
|
||||
let(:message) { create(:message, conversation: conversation, account: account, sender: another_agent) }
|
||||
let(:mail) { described_class.with(account: account).conversation_mention(message, agent).deliver_now }
|
||||
let(:contact_inbox) { create(:contact_inbox, account: account, inbox: conversation.inbox) }
|
||||
|
||||
before do
|
||||
create(:message, conversation: conversation, account: account, sender: contact)
|
||||
create(:message, conversation: conversation, account: account, sender: contact)
|
||||
create(:message, conversation: conversation, account: account, sender: contact)
|
||||
end
|
||||
|
||||
it 'renders the subject' do
|
||||
expect(mail.subject).to eq("#{agent.available_name}, You have been mentioned in conversation [ID - #{conversation.display_id}]")
|
||||
|
@ -54,6 +62,12 @@ RSpec.describe AgentNotifications::ConversationNotificationsMailer, type: :maile
|
|||
it 'renders the senders name' do
|
||||
expect(mail.body.encoded).to match("You've been mentioned in a conversation. <b>#{another_agent.display_name}</b> wrote:")
|
||||
end
|
||||
|
||||
it 'renders Customer if contacts name not available in the conversation' do
|
||||
expect(contact.name).to be_nil
|
||||
expect(conversation.recent_messages).not_to be_empty
|
||||
expect(mail.body.encoded).to match('Incoming Message')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'assigned_conversation_new_message' do
|
||||
|
|
Loading…
Reference in a new issue