Commit 35ae1656 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch '335355-rename-scopes' into 'master'

Rename .inherit and .not_inherited scopes in Integration

See merge request gitlab-org/gitlab!67201
parents 6256547a 1169d1e9
...@@ -12,7 +12,7 @@ class Admin::IntegrationsController < Admin::ApplicationController ...@@ -12,7 +12,7 @@ class Admin::IntegrationsController < Admin::ApplicationController
respond_to do |format| respond_to do |format|
format.json do format.json do
projects = Project.with_active_integration(integration.class).merge(::Integration.not_inherited) projects = Project.with_active_integration(integration.class).merge(::Integration.with_custom_settings)
serializer = ::Integrations::ProjectSerializer.new.with_pagination(request, response) serializer = ::Integrations::ProjectSerializer.new.with_pagination(request, response)
render json: serializer.represent(projects) render json: serializer.represent(projects)
......
...@@ -77,8 +77,8 @@ class Integration < ApplicationRecord ...@@ -77,8 +77,8 @@ class Integration < ApplicationRecord
scope :by_type, -> (type) { where(type: type) } scope :by_type, -> (type) { where(type: type) }
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 :with_default_settings, -> { where.not(inherit_from_id: nil) }
scope :not_inherited, -> { where(inherit_from_id: nil) } scope :with_custom_settings, -> { where(inherit_from_id: nil) }
scope :for_group, -> (group) { where(group_id: group, type: available_integration_types(include_project_specific: false)) } scope :for_group, -> (group) { where(group_id: group, type: available_integration_types(include_project_specific: false)) }
scope :for_instance, -> { where(instance: true, type: available_integration_types(include_project_specific: false)) } scope :for_instance, -> { where(instance: true, type: available_integration_types(include_project_specific: false)) }
......
...@@ -208,12 +208,12 @@ module Groups ...@@ -208,12 +208,12 @@ module Groups
end end
def update_integrations def update_integrations
@group.integrations.inherit.delete_all @group.integrations.with_default_settings.delete_all
Integration.create_from_active_default_integrations(@group, :group_id) Integration.create_from_active_default_integrations(@group, :group_id)
end end
def propagate_integrations def propagate_integrations
@group.integrations.inherit.each do |integration| @group.integrations.with_default_settings.each do |integration|
PropagateIntegrationWorker.perform_async(integration.id) PropagateIntegrationWorker.perform_async(integration.id)
end end
end end
......
...@@ -241,7 +241,7 @@ module Projects ...@@ -241,7 +241,7 @@ module Projects
end end
def update_integrations def update_integrations
project.integrations.inherit.delete_all project.integrations.with_default_settings.delete_all
Integration.create_from_active_default_integrations(project, :project_id) Integration.create_from_active_default_integrations(project, :project_id)
end end
end end
......
...@@ -61,21 +61,21 @@ RSpec.describe Integration do ...@@ -61,21 +61,21 @@ RSpec.describe Integration do
end end
describe 'Scopes' do describe 'Scopes' do
describe '.inherit' do describe '.with_default_settings' do
it 'returns the correct integrations' do it 'returns the correct integrations' do
instance_integration = create(:integration, :instance) instance_integration = create(:integration, :instance)
inheriting_integration = create(:integration, inherit_from_id: instance_integration.id) inheriting_integration = create(:integration, inherit_from_id: instance_integration.id)
expect(described_class.inherit).to match_array([inheriting_integration]) expect(described_class.with_default_settings).to match_array([inheriting_integration])
end end
end end
describe '.not_inherited' do describe '.with_custom_settings' do
it 'returns the correct integrations' do it 'returns the correct integrations' do
instance_integration = create(:integration, :instance) instance_integration = create(:integration, :instance)
create(:integration, inherit_from_id: instance_integration.id) create(:integration, inherit_from_id: instance_integration.id)
expect(described_class.not_inherited).to match_array([instance_integration]) expect(described_class.with_custom_settings).to match_array([instance_integration])
end end
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