Commit 929dd0d8 authored by Leni Kadali Mutungi's avatar Leni Kadali Mutungi Committed by Arturo Herrero

Ignore template column in Integration model

As part of dropping the template column from
the integrations table, we need to ignore
the column in the application code.
parent 0c033a97
...@@ -9,6 +9,9 @@ class Integration < ApplicationRecord ...@@ -9,6 +9,9 @@ class Integration < ApplicationRecord
include Integrations::HasDataFields include Integrations::HasDataFields
include FromUnion include FromUnion
include EachBatch include EachBatch
include IgnorableColumns
ignore_column :template, remove_with: '14.10', remove_after: '2022-03-22'
INTEGRATION_NAMES = %w[ INTEGRATION_NAMES = %w[
asana assembla bamboo bugzilla buildkite campfire confluence custom_issue_tracker datadog discord asana assembla bamboo bugzilla buildkite campfire confluence custom_issue_tracker datadog discord
......
...@@ -145,7 +145,7 @@ module Integrations ...@@ -145,7 +145,7 @@ module Integrations
end end
def one_issue_tracker def one_issue_tracker
return if template? || instance? return if instance?
return if project.blank? return if project.blank?
if project.integrations.external_issue_trackers.where.not(id: id).any? if project.integrations.external_issue_trackers.where.not(id: id).any?
......
...@@ -115,7 +115,6 @@ module Integrations ...@@ -115,7 +115,6 @@ module Integrations
end end
def prometheus_available? def prometheus_available?
return false if template?
return false unless project return false unless project
project.all_clusters.enabled.eager_load(:integration_prometheus).any? do |cluster| project.all_clusters.enabled.eager_load(:integration_prometheus).any? do |cluster|
......
...@@ -32,11 +32,7 @@ class BulkCreateIntegrationService ...@@ -32,11 +32,7 @@ class BulkCreateIntegrationService
end end
def integration_hash def integration_hash
if integration.template? integration.to_integration_hash.tap { |json| json['inherit_from_id'] = integration.inherit_from_id || integration.id }
integration.to_integration_hash
else
integration.to_integration_hash.tap { |json| json['inherit_from_id'] = integration.inherit_from_id || integration.id }
end
end end
def data_fields_hash 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 ...@@ -217,11 +217,6 @@ FactoryBot.define do
end end
end end
trait :template do
project { nil }
template { true }
end
trait :group do trait :group do
group group
project { nil } project { nil }
......
...@@ -9,7 +9,7 @@ RSpec.describe Gitlab::Integrations::StiType do ...@@ -9,7 +9,7 @@ RSpec.describe Gitlab::Integrations::StiType do
context 'SQL SELECT' do context 'SQL SELECT' do
let(:expected_sql) do let(:expected_sql) do
<<~SQL.strip <<~SQL.strip
SELECT "integrations".* FROM "integrations" WHERE "integrations"."type" = 'AsanaService' FROM "integrations" WHERE "integrations"."type" = 'AsanaService'
SQL SQL
end end
...@@ -18,7 +18,7 @@ RSpec.describe Gitlab::Integrations::StiType do ...@@ -18,7 +18,7 @@ RSpec.describe Gitlab::Integrations::StiType do
Integration.where(type: type).to_sql Integration.where(type: type).to_sql
end end
expect(sql_statements).to all(eq(expected_sql)) expect(sql_statements).to all(end_with(expected_sql))
end end
end end
......
...@@ -268,7 +268,7 @@ RSpec.describe Integration do ...@@ -268,7 +268,7 @@ RSpec.describe Integration do
describe '.build_from_integration' do describe '.build_from_integration' do
context 'when integration is invalid' do context 'when integration is invalid' do
let(:invalid_integration) 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) } .tap { |integration| integration.save!(validate: false) }
end end
......
...@@ -13,7 +13,6 @@ RSpec.describe BulkCreateIntegrationService do ...@@ -13,7 +13,6 @@ RSpec.describe BulkCreateIntegrationService do
let_it_be(:excluded_project) { create(:project, group: excluded_group) } let_it_be(:excluded_project) { create(:project, group: excluded_group) }
let(:instance_integration) { create(:jira_integration, :instance) } 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] } 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 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