Commit 8b9084b4 authored by Alex Kalderimis's avatar Alex Kalderimis

Rename asana_service

Renames `asana_service` to `asana_integration`
parent d0e635a0
......@@ -6,7 +6,14 @@ module Types
graphql_name 'ServiceType'
::Integration.available_services_types(include_dev: false).each do |service_type|
value service_type.underscore.upcase, value: service_type, description: "#{service_type} type"
replacement = Integration.integration_type_for_service_type(service_type)
deprecation = { reason: :renamed, replacement: replacement, milestone: '14.0' } if replacement.present?
value service_type.underscore.upcase, value: service_type, description: "#{service_type} type", deprecation: deprecation
end
::Integration.available_integration_types(include_dev: false).each do |type|
value type.underscore.upcase, value: type, description: "#{type} integration"
end
end
end
......
......@@ -219,6 +219,7 @@ class Integration < ApplicationRecord
# Returns a list of available service names.
# Example: ["asana", ...]
# @deprecated
def self.available_services_names(include_project_specific: true, include_dev: true)
service_names = services_names
service_names += project_specific_services_names if include_project_specific
......@@ -227,10 +228,22 @@ class Integration < ApplicationRecord
service_names.sort_by(&:downcase)
end
def self.services_names
# used as part of the renaming effort
RENAMED_TO_INTEGRATION = %w[asana]
def self.available_integration_names(**args)
available_services_names(**args)
.select { RENAMED_TO_INTEGRATION.include?(_1) }
end
def self.integration_names
INTEGRATION_NAMES
end
def self.services_names
integration_names
end
def self.dev_services_names
return [] unless Rails.env.development?
......@@ -249,6 +262,18 @@ class Integration < ApplicationRecord
end
end
def self.available_integration_types(include_project_specific: true, include_dev: true)
available_integration_names(include_project_specific: include_project_specific, include_dev: include_dev).map do |name|
integration_name_to_type(name)
end
end
def self.integration_type_for_service_type(type_name)
name = type_name.chomp(type_name)
integration_name_to_type(name) if RENAMED_TO_INTEGRATION.include?(name)
end
# Returns the model for the given service name.
# Example: "asana" => Integrations::Asana
def self.service_name_to_model(name)
......@@ -262,6 +287,10 @@ class Integration < ApplicationRecord
"#{name}_service".camelize
end
def self.integration_name_to_type(name)
"#{name}_integration".camelize
end
# Returns the model for the given STI type.
# Example: "AsanaService" => Integrations::Asana
def self.service_type_to_model(type)
......
......@@ -155,7 +155,7 @@ class Project < ApplicationRecord
has_many :boards
# Project integrations
has_one :asana_service, class_name: 'Integrations::Asana'
has_one :asana_integration, class_name: 'Integrations::Asana'
has_one :assembla_service, class_name: 'Integrations::Assembla'
has_one :bamboo_service, class_name: 'Integrations::Bamboo'
has_one :bugzilla_service, class_name: 'Integrations::Bugzilla'
......
......@@ -377,7 +377,7 @@ project:
- prometheus_service
- flowdock_service
- assembla_service
- asana_service
- asana_integration
- slack_service
- microsoft_teams_service
- mattermost_service
......
......@@ -43,7 +43,7 @@ RSpec.describe Project, factory_default: :keep do
it { is_expected.to have_one(:webex_teams_service) }
it { is_expected.to have_one(:packagist_service) }
it { is_expected.to have_one(:pushover_service) }
it { is_expected.to have_one(:asana_service) }
it { is_expected.to have_one(:asana_integration) }
it { is_expected.to have_many(:boards) }
it { is_expected.to have_one(:campfire_service) }
it { is_expected.to have_one(:datadog_service) }
......
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