feat: notify on slack disconnect (#1323)

This commit is contained in:
Abhishek
2020-10-28 02:52:57 +08:00
committed by GitHub
parent 9045b8d9ca
commit ff96d43953
6 changed files with 58 additions and 7 deletions

View File

@@ -27,5 +27,24 @@ describe Integrations::Slack::SendOnSlackService do
builder.perform
end
it 'disables hook on Slack AccountInactive error' do
builder = described_class.new(message: message, hook: hook)
slack_client = double
expect(builder).to receive(:slack_client).and_return(slack_client)
expect(slack_client).to receive(:chat_postMessage).with(
channel: hook.reference_id,
text: message.content,
username: "Contact: #{message.sender.name}",
thread_ts: conversation.identifier,
icon_url: anything
).and_raise(Slack::Web::Api::Errors::AccountInactive.new('Account disconnected'))
allow(hook).to receive(:authorization_error!)
builder.perform
expect(hook).to be_disabled
expect(hook).to have_received(:authorization_error!)
end
end
end