diff --git a/app/models/integrations/jira.rb b/app/models/integrations/jira.rb index a30e3d868da72bd86326f9d52c3f9ea549d37b18..bd1f3846a41eb51dd681f0d7e4f63d5daf06d091 100644 --- a/app/models/integrations/jira.rb +++ b/app/models/integrations/jira.rb @@ -7,6 +7,7 @@ class Jira < BaseIssueTracker include ApplicationHelper include ActionView::Helpers::AssetUrlHelper include Gitlab::Utils::StrongMemoize + include HasAvatar PROJECTS_PER_PAGE = 50 JIRA_CLOUD_HOST = '.atlassian.net' @@ -404,10 +405,6 @@ def personal_access_token_authorization? jira_auth_type == AUTH_TYPE_PAT end - def avatar_url - ActionController::Base.helpers.image_path('illustrations/third-party-logos/integrations-logos/jira.svg') - end - def testable? group_level? || project_level? end diff --git a/app/models/integrations/pushover.rb b/app/models/integrations/pushover.rb index b2c4e06e71f1c3f391efaea8f4caa00c1d9e2ebf..53d6e677fb06b0be3669fc906176f28acb14b8d1 100644 --- a/app/models/integrations/pushover.rb +++ b/app/models/integrations/pushover.rb @@ -2,6 +2,7 @@ module Integrations class Pushover < Integration + include HasAvatar BASE_URI = 'https://api.pushover.net/1' validates :api_key, :user_key, :priority, presence: true, if: :activated? @@ -125,9 +126,5 @@ def execute(data) Gitlab::HTTP.post('/messages.json', base_uri: BASE_URI, body: pushover_data) end - - def avatar_url - ActionController::Base.helpers.image_path('illustrations/third-party-logos/integrations-logos/pushover.svg') - end end end diff --git a/app/models/integrations/telegram.rb b/app/models/integrations/telegram.rb index 8eb1a7ad0ea346b9c6a7b58bb1a8fce2af6f658d..506705067049ebae03d7381f35686cf3b56e1df6 100644 --- a/app/models/integrations/telegram.rb +++ b/app/models/integrations/telegram.rb @@ -2,6 +2,7 @@ module Integrations class Telegram < BaseChatNotification + include HasAvatar TELEGRAM_HOSTNAME = "https://api.telegram.org/bot%{token}/sendMessage" field :token, @@ -66,10 +67,6 @@ def self.supported_events super - ['deployment'] end - def avatar_url - ActionController::Base.helpers.image_path('illustrations/third-party-logos/integrations-logos/telegram.svg') - end - private def set_webhook diff --git a/spec/models/integrations/jira_spec.rb b/spec/models/integrations/jira_spec.rb index 36af9c2daf7402c8f6772083cb4d5976c3df1ff9..ad925807df14c22bbdb3f000285f667521bff692 100644 --- a/spec/models/integrations/jira_spec.rb +++ b/spec/models/integrations/jira_spec.rb @@ -32,6 +32,8 @@ WebMock.stub_request(:get, /serverInfo/).to_return(body: server_info_results.to_json) end + it_behaves_like Integrations::HasAvatar + it_behaves_like Integrations::ResetSecretFields do let(:integration) { jira_integration } end @@ -1393,12 +1395,4 @@ def server_info end end end - - describe '#avatar_url' do - it 'returns the avatar image path' do - expect(subject.avatar_url).to eq( - ActionController::Base.helpers.image_path('illustrations/third-party-logos/integrations-logos/jira.svg') - ) - end - end end diff --git a/spec/models/integrations/pushover_spec.rb b/spec/models/integrations/pushover_spec.rb index c576340a78abc7c098004ccc113cf7ba72ab8466..60d81b45d2f7e8389656a22c7d71f1ba28f4cd30 100644 --- a/spec/models/integrations/pushover_spec.rb +++ b/spec/models/integrations/pushover_spec.rb @@ -2,9 +2,11 @@ require 'spec_helper' -RSpec.describe Integrations::Pushover do +RSpec.describe Integrations::Pushover, feature_category: :integrations do include StubRequests + it_behaves_like Integrations::HasAvatar + describe 'Validations' do context 'when integration is active' do before do @@ -62,12 +64,4 @@ expect(WebMock).to have_requested(:post, 'https://8.8.8.8/1/messages.json').once end end - - describe '#avatar_url' do - it 'returns the avatar image path' do - expect(subject.avatar_url).to eq( - ActionController::Base.helpers.image_path('illustrations/third-party-logos/integrations-logos/pushover.svg') - ) - end - end end diff --git a/spec/models/integrations/telegram_spec.rb b/spec/models/integrations/telegram_spec.rb index 4c814dedd6631cfb8247990317c88c1456484aa7..a5c9ed9cb53bbc4095df1677ee1afc02ea21e386 100644 --- a/spec/models/integrations/telegram_spec.rb +++ b/spec/models/integrations/telegram_spec.rb @@ -3,6 +3,7 @@ require "spec_helper" RSpec.describe Integrations::Telegram, feature_category: :integrations do + it_behaves_like Integrations::HasAvatar it_behaves_like "chat integration", "Telegram" do let(:payload) do { @@ -50,12 +51,4 @@ end end end - - describe '#avatar_url' do - it 'returns the avatar image path' do - expect(subject.avatar_url).to eq( - ActionController::Base.helpers.image_path('illustrations/third-party-logos/integrations-logos/telegram.svg') - ) - end - end end