Commit 35ad14f7 authored by Markus Koller's avatar Markus Koller

Rename base class for issue tracker integrations

This adds the `Base` prefix to make it clear that this is a base class
for other integrations, and not an actual integration itself.

We're also merging the EE extension module, which is a leftover from
when we moved the Jira integration into CE in f177aaa5.
parent 52bf1812
......@@ -29,7 +29,7 @@ module Mentionable
def self.external_pattern
strong_memoize(:external_pattern) do
issue_pattern = Integrations::IssueTracker.reference_pattern
issue_pattern = Integrations::BaseIssueTracker.reference_pattern
link_patterns = URI::DEFAULT_PARSER.make_regexp(%w(http https))
reference_pattern(link_patterns, issue_pattern)
end
......
# frozen_string_literal: true
module Integrations
class IssueTracker < Integration
class BaseIssueTracker < Integration
validate :one_issue_tracker, if: :activated?, on: :manual_change
# TODO: we can probably just delegate as part of
......@@ -128,6 +128,10 @@ module Integrations
false
end
def create_cross_reference_note(mentioned, noteable, author)
# implement inside child
end
private
def enabled_in_gitlab_config
......@@ -150,5 +154,3 @@ module Integrations
end
end
end
Integrations::IssueTracker.prepend_mod_with('Integrations::IssueTracker')
# frozen_string_literal: true
module Integrations
class Bugzilla < IssueTracker
class Bugzilla < BaseIssueTracker
include ActionView::Helpers::UrlHelper
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated?
......
# frozen_string_literal: true
module Integrations
class CustomIssueTracker < IssueTracker
class CustomIssueTracker < BaseIssueTracker
include ActionView::Helpers::UrlHelper
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated?
......
# frozen_string_literal: true
module Integrations
class Ewm < IssueTracker
class Ewm < BaseIssueTracker
include ActionView::Helpers::UrlHelper
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated?
......
......@@ -2,7 +2,7 @@
# Accessible as Project#external_issue_tracker
module Integrations
class Jira < IssueTracker
class Jira < BaseIssueTracker
extend ::Gitlab::Utils::Override
include Gitlab::Routing
include ApplicationHelper
......@@ -205,6 +205,7 @@ module Integrations
log_usage(:close_issue, current_user)
end
override :create_cross_reference_note
def create_cross_reference_note(mentioned, noteable, author)
unless can_cross_reference?(noteable)
return s_("JiraService|Events for %{noteable_model_name} are disabled.") % { noteable_model_name: noteable.model_name.plural.humanize(capitalize: false) }
......
# frozen_string_literal: true
module Integrations
class OpenProject < IssueTracker
class OpenProject < BaseIssueTracker
validates :url, public_url: true, presence: true, if: :activated?
validates :api_url, public_url: true, allow_blank: true, if: :activated?
validates :token, presence: true, if: :activated?
......
# frozen_string_literal: true
module Integrations
class Redmine < IssueTracker
class Redmine < BaseIssueTracker
include ActionView::Helpers::UrlHelper
validates :project_url, :issues_url, :new_issue_url, presence: true, public_url: true, if: :activated?
......
# frozen_string_literal: true
module Integrations
class Youtrack < IssueTracker
class Youtrack < BaseIssueTracker
include ActionView::Helpers::UrlHelper
validates :project_url, :issues_url, presence: true, public_url: true, if: :activated?
......
# frozen_string_literal: true
module EE
module Integrations
module IssueTracker
def create_cross_reference_note
# implement inside child
end
end
end
end
......@@ -5,7 +5,7 @@ module Gitlab
class StiType < ActiveRecord::Type::String
NAMESPACED_INTEGRATIONS = Set.new(%w(
Asana Assembla Bamboo Bugzilla Buildkite Campfire Confluence CustomIssueTracker Datadog
Discord DroneCi EmailsOnPush Ewm ExternalWiki Flowdock HangoutsChat IssueTracker Irker
Discord DroneCi EmailsOnPush Ewm ExternalWiki Flowdock HangoutsChat Irker
Jenkins Jira Mattermost MattermostSlashCommands MicrosoftTeams MockCi Packagist PipelinesEmail Pivotaltracker
Pushover Redmine Slack SlackSlashCommands Teamcity UnifyCircuit Youtrack WebexTeams
)).freeze
......
......@@ -188,13 +188,13 @@ FactoryBot.define do
create_data { false }
after(:build) do
Integrations::IssueTracker.skip_callback(:validation, :before, :handle_properties)
Integrations::BaseIssueTracker.skip_callback(:validation, :before, :handle_properties)
end
to_create { |instance| instance.save!(validate: false) }
after(:create) do
Integrations::IssueTracker.set_callback(:validation, :before, :handle_properties)
Integrations::BaseIssueTracker.set_callback(:validation, :before, :handle_properties)
end
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Integrations::IssueTracker do
RSpec.describe Integrations::BaseIssueTracker do
describe 'Validations' do
let(:project) { create :project }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment