feat: Change slack bot and activity message appearance (#8349)

This commit is contained in:
Muhsin Keloth
2023-11-16 12:59:52 +05:30
committed by GitHub
parent 5f6e974531
commit 5f503b1a57
4 changed files with 35 additions and 5 deletions

View File

@@ -183,11 +183,11 @@ describe Integrations::Slack::SendOnSlackService do
it 'sent a template message on slack' do
builder = described_class.new(message: template_message, hook: hook)
allow(builder).to receive(:slack_client).and_return(slack_client)
template_message.update!(sender: nil)
expect(slack_client).to receive(:chat_postMessage).with(
channel: hook.reference_id,
text: template_message.content,
username: "#{template_message.sender.name} (Contact)",
username: 'Bot',
thread_ts: conversation.identifier,
icon_url: anything,
unfurl_links: true
@@ -198,6 +198,24 @@ describe Integrations::Slack::SendOnSlackService do
expect(template_message.external_source_id_slack).to eq 'cw-origin-6789.12345'
end
it 'sent a activity message on slack' do
template_message.update!(message_type: :activity)
template_message.update!(sender: nil)
builder = described_class.new(message: template_message, hook: hook)
allow(builder).to receive(:slack_client).and_return(slack_client)
expect(slack_client).to receive(:chat_postMessage).with(
channel: hook.reference_id,
text: "_#{template_message.content}_",
username: 'System',
thread_ts: conversation.identifier,
icon_url: anything,
unfurl_links: true
).and_return(slack_message)
builder.perform
expect(template_message.external_source_id_slack).to eq 'cw-origin-6789.12345'
end
it 'disables hook on Slack AccountInactive error' do
expect(slack_client).to receive(:chat_postMessage).with(
channel: hook.reference_id,