chore: Add subject to the slack message (#6404)
This commit is contained in:
@@ -2,7 +2,8 @@ require 'rails_helper'
|
||||
|
||||
describe Integrations::Slack::SendOnSlackService do
|
||||
let!(:contact) { create(:contact) }
|
||||
let!(:conversation) { create(:conversation, contact: contact, identifier: nil) }
|
||||
let(:channel_email) { create(:channel_email) }
|
||||
let!(:conversation) { create(:conversation, inbox: channel_email.inbox, contact: contact, identifier: nil) }
|
||||
let(:account) { conversation.account }
|
||||
let!(:hook) { create(:integrations_hook, account: account) }
|
||||
let!(:message) do
|
||||
@@ -38,6 +39,32 @@ describe Integrations::Slack::SendOnSlackService do
|
||||
|
||||
expect(conversation.reload.identifier).to eq '12345.6789'
|
||||
end
|
||||
|
||||
context 'with subject line in email' do
|
||||
let(:message) do
|
||||
create(:message,
|
||||
content_attributes: { 'email': { 'subject': 'Sample subject line' } },
|
||||
content: 'Sample Body',
|
||||
account: conversation.account,
|
||||
inbox: conversation.inbox, conversation: conversation)
|
||||
end
|
||||
|
||||
it 'creates slack message with subject line' do
|
||||
inbox = conversation.inbox
|
||||
|
||||
expect(slack_client).to receive(:chat_postMessage).with(
|
||||
channel: hook.reference_id,
|
||||
text: "\n*Inbox:* #{inbox.name} (#{inbox.inbox_type})\n*Subject:* Sample subject line\n\n\n#{message.content}",
|
||||
username: "#{message.sender.name} (Contact)",
|
||||
thread_ts: nil,
|
||||
icon_url: anything
|
||||
).and_return(slack_message)
|
||||
|
||||
builder.perform
|
||||
|
||||
expect(conversation.reload.identifier).to eq '12345.6789'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with identifier' do
|
||||
|
||||
Reference in New Issue
Block a user