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