Commit b8c957ad authored by Alex Kalderimis's avatar Alex Kalderimis

Rename available integration type listing method

Renames available_services_names to available_integration_types
parent a4d50620
......@@ -5,7 +5,7 @@ module Types
class ServiceTypeEnum < BaseEnum
graphql_name 'ServiceType'
::Integration.available_services_types(include_dev: false).each do |type|
::Integration.available_integration_types(include_dev: false).each do |type|
value type.underscore.upcase, value: type, description: "#{type} type"
end
end
......
......@@ -108,9 +108,9 @@ class Integration < ApplicationRecord
scope :by_active_flag, -> (flag) { where(active: flag) }
scope :inherit_from_id, -> (id) { where(inherit_from_id: id) }
scope :inherit, -> { where.not(inherit_from_id: nil) }
scope :for_group, -> (group) { where(group_id: group, type: available_services_types(include_project_specific: false)) }
scope :for_template, -> { where(template: true, type: available_services_types(include_project_specific: false)) }
scope :for_instance, -> { where(instance: true, type: available_services_types(include_project_specific: false)) }
scope :for_group, -> (group) { where(group_id: group, type: available_integration_types(include_project_specific: false)) }
scope :for_template, -> { where(template: true, type: available_integration_types(include_project_specific: false)) }
scope :for_instance, -> { where(instance: true, type: available_integration_types(include_project_specific: false)) }
scope :push_hooks, -> { where(push_events: true, active: true) }
scope :tag_push_hooks, -> { where(tag_push_events: true, active: true) }
......@@ -238,7 +238,7 @@ class Integration < ApplicationRecord
def self.nonexistent_services_types_for(scope)
# Using #map instead of #pluck to save one query count. This is because
# ActiveRecord loaded the object here, so we don't need to query again later.
available_services_types(include_project_specific: false) - scope.map(&:type)
available_integration_types(include_project_specific: false) - scope.map(&:type)
end
private_class_method :nonexistent_services_types_for
......@@ -271,11 +271,11 @@ class Integration < ApplicationRecord
PROJECT_SPECIFIC_INTEGRATION_NAMES
end
# Returns a list of available service types.
# Returns a list of available integration types.
# Example: ["AsanaService", ...]
def self.available_services_types(include_project_specific: true, include_dev: true)
available_integration_names(include_project_specific: include_project_specific, include_dev: include_dev).map do |service_name|
integration_name_to_type(service_name)
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
integration_name_to_type(_1)
end
end
......
......@@ -8,6 +8,6 @@ RSpec.describe GitlabSchema.types['ServiceType'] do
end
def available_services_enum
::Integration.available_services_types(include_dev: false).map(&:underscore).map(&:upcase)
::Integration.available_integration_types(include_dev: false).map(&:underscore).map(&:upcase)
end
end
......@@ -140,10 +140,10 @@ RSpec.describe Integration do
end
describe "Test Button" do
let(:service) { build(:service, project: project) }
let(:integration) { build(:service, project: project) }
describe '#can_test?' do
subject { service.can_test? }
subject { integration.can_test? }
context 'when repository is not empty' do
let(:project) { build(:project, :repository) }
......@@ -158,9 +158,9 @@ RSpec.describe Integration do
end
context 'when instance-level service' do
Integration.available_services_types.each do |service_type|
let(:service) do
described_class.send(:integration_type_to_model, service_type).new(instance: true)
Integration.available_integration_types.each do |type|
let(:integration) do
described_class.send(:integration_type_to_model, type).new(instance: true)
end
it { is_expected.to be_falsey }
......@@ -168,9 +168,9 @@ RSpec.describe Integration do
end
context 'when group-level service' do
Integration.available_services_types.each do |service_type|
let(:service) do
described_class.send(:integration_type_to_model, service_type).new(group_id: group.id)
Integration.available_integration_types.each do |type|
let(:integration) do
described_class.send(:integration_type_to_model, type).new(group_id: group.id)
end
it { is_expected.to be_falsey }
......@@ -266,7 +266,7 @@ RSpec.describe Integration do
context 'with all existing instances' do
before do
Integration.insert_all(
Integration.available_services_types(include_project_specific: false).map { |type| { instance: true, type: type } }
Integration.available_integration_types(include_project_specific: false).map { |type| { instance: true, type: type } }
)
end
......@@ -294,7 +294,7 @@ RSpec.describe Integration do
describe 'template' do
shared_examples 'retrieves service templates' do
it 'returns the available service templates' do
expect(Integration.find_or_create_templates.pluck(:type)).to match_array(Integration.available_services_types(include_project_specific: false))
expect(Integration.find_or_create_templates.pluck(:type)).to match_array(Integration.available_integration_types(include_project_specific: false))
end
end
......@@ -310,7 +310,7 @@ RSpec.describe Integration do
context 'with all existing templates' do
before do
Integration.insert_all(
Integration.available_services_types(include_project_specific: false).map { |type| { template: true, type: type } }
Integration.available_integration_types(include_project_specific: false).map { |type| { template: true, type: type } }
)
end
......
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