Fix mattermost icon selection
This commit is contained in:
parent
5f555849e5
commit
da9ee8dcb5
|
@ -44,7 +44,7 @@ module DiscourseChat
|
|||
end
|
||||
|
||||
icon_url =
|
||||
if !SiteSetting.chat_integration_slack_icon_url.blank?
|
||||
if !SiteSetting.chat_integration_mattermost_icon_url.blank?
|
||||
UrlHelper.absolute(SiteSetting.chat_integration_mattermost_icon_url)
|
||||
elsif !SiteSetting.logo_small_url.blank?
|
||||
UrlHelper.absolute(SiteSetting.logo_small_url)
|
||||
|
|
|
@ -7,6 +7,7 @@ RSpec.describe DiscourseChat::Provider::MattermostProvider do
|
|||
before do
|
||||
SiteSetting.chat_integration_mattermost_enabled = true
|
||||
SiteSetting.chat_integration_mattermost_webhook_url = "https://mattermost.blah/hook/abcd"
|
||||
SiteSetting.logo_small_url = "https://some_small_logo"
|
||||
end
|
||||
|
||||
let(:chan1) { DiscourseChat::Channel.create!(provider: 'mattermost', data: { identifier: "#awesomechannel" }) }
|
||||
|
@ -17,6 +18,21 @@ RSpec.describe DiscourseChat::Provider::MattermostProvider do
|
|||
expect(stub1).to have_been_requested.once
|
||||
end
|
||||
|
||||
describe 'when mattermost icon is not configured' do
|
||||
it 'defaults to the right icon' do
|
||||
message = described_class.mattermost_message(post, chan1)
|
||||
expect(message[:icon_url]).to eq(SiteSetting.logo_small_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when mattermost icon has been configured' do
|
||||
it 'should use the right icon' do
|
||||
SiteSetting.chat_integration_mattermost_icon_url = "https://specific_logo"
|
||||
message = described_class.mattermost_message(post, chan1)
|
||||
expect(message[:icon_url]).to eq(SiteSetting.chat_integration_mattermost_icon_url)
|
||||
end
|
||||
end
|
||||
|
||||
it 'handles errors correctly' do
|
||||
stub1 = stub_request(:post, "https://mattermost.blah/hook/abcd").to_return(status: 500, body: "error")
|
||||
expect(stub1).to have_been_requested.times(0)
|
||||
|
|
Loading…
Reference in New Issue