diff --git a/lib/discourse_chat/provider/mattermost/mattermost_provider.rb b/lib/discourse_chat/provider/mattermost/mattermost_provider.rb index cb3fa0f..02573db 100644 --- a/lib/discourse_chat/provider/mattermost/mattermost_provider.rb +++ b/lib/discourse_chat/provider/mattermost/mattermost_provider.rb @@ -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) diff --git a/spec/lib/discourse_chat/provider/mattermost/mattermost_provider_spec.rb b/spec/lib/discourse_chat/provider/mattermost/mattermost_provider_spec.rb index 746c605..aa608bd 100644 --- a/spec/lib/discourse_chat/provider/mattermost/mattermost_provider_spec.rb +++ b/spec/lib/discourse_chat/provider/mattermost/mattermost_provider_spec.rb @@ -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)