Commit c5cd56d7 authored by Arturo Herrero's avatar Arturo Herrero

Merge branch '335181-ignore-template-column-in-integrations-table' into 'master'

Ignore template column in Integration model

See merge request gitlab-org/gitlab!80514
parents 1cdc91a9 929dd0d8
......@@ -9,6 +9,9 @@ class Integration < ApplicationRecord
include Integrations::HasDataFields
include FromUnion
include EachBatch
include IgnorableColumns
ignore_column :template, remove_with: '14.10', remove_after: '2022-03-22'
INTEGRATION_NAMES = %w[
asana assembla bamboo bugzilla buildkite campfire confluence custom_issue_tracker datadog discord
......
......@@ -145,7 +145,7 @@ module Integrations
end
def one_issue_tracker
return if template? || instance?
return if instance?
return if project.blank?
if project.integrations.external_issue_trackers.where.not(id: id).any?
......
......@@ -115,7 +115,6 @@ module Integrations
end
def prometheus_available?
return false if template?
return false unless project
project.all_clusters.enabled.eager_load(:integration_prometheus).any? do |cluster|
......
......@@ -32,11 +32,7 @@ class BulkCreateIntegrationService
end
def integration_hash
if integration.template?
integration.to_integration_hash
else
integration.to_integration_hash.tap { |json| json['inherit_from_id'] = integration.inherit_from_id || integration.id }
end
integration.to_integration_hash.tap { |json| json['inherit_from_id'] = integration.inherit_from_id || integration.id }
end
def data_fields_hash
......
# frozen_string_literal: true
module Integrations
# TODO: Remove this as part of https://gitlab.com/gitlab-org/gitlab/-/issues/335178
class PropagateTemplateService
def self.propagate(_integration)
# no-op
end
end
end
......@@ -217,11 +217,6 @@ FactoryBot.define do
end
end
trait :template do
project { nil }
template { true }
end
trait :group do
group
project { nil }
......
......@@ -9,7 +9,7 @@ RSpec.describe Gitlab::Integrations::StiType do
context 'SQL SELECT' do
let(:expected_sql) do
<<~SQL.strip
SELECT "integrations".* FROM "integrations" WHERE "integrations"."type" = 'AsanaService'
FROM "integrations" WHERE "integrations"."type" = 'AsanaService'
SQL
end
......@@ -18,7 +18,7 @@ RSpec.describe Gitlab::Integrations::StiType do
Integration.where(type: type).to_sql
end
expect(sql_statements).to all(eq(expected_sql))
expect(sql_statements).to all(end_with(expected_sql))
end
end
......
......@@ -268,7 +268,7 @@ RSpec.describe Integration do
describe '.build_from_integration' do
context 'when integration is invalid' do
let(:invalid_integration) do
build(:prometheus_integration, :template, active: true, properties: {})
build(:prometheus_integration, :instance, active: true, properties: {})
.tap { |integration| integration.save!(validate: false) }
end
......
......@@ -13,7 +13,6 @@ RSpec.describe BulkCreateIntegrationService do
let_it_be(:excluded_project) { create(:project, group: excluded_group) }
let(:instance_integration) { create(:jira_integration, :instance) }
let(:template_integration) { create(:jira_integration, :template) }
let(:excluded_attributes) { %w[id project_id group_id inherit_from_id instance template created_at updated_at] }
shared_examples 'creates integration from batch ids' do
......
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