Commit 6071fca1 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'switch_acts_as_taggable_db_connection' into 'master'

Switch ActsOnTaggable model's DB connection to ci database

See merge request gitlab-org/gitlab!73523
parents 48a39711 7fe837cc
......@@ -9,3 +9,9 @@ ActsAsTaggableOn.tags_counter = false
# validate that counter cache is disabled
raise "Counter cache is not disabled" if
ActsAsTaggableOn::Tagging.reflections["tag"].options[:counter_cache]
# Redirects retrieve_connection to use Ci::ApplicationRecord's connection
[::ActsAsTaggableOn::Tag, ::ActsAsTaggableOn::Tagging].each do |model|
model.connection_specification_name = Ci::ApplicationRecord.connection_specification_name
model.singleton_class.delegate :connection, :sticking, to: '::Ci::ApplicationRecord'
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ActsAsTaggableOn::Tag do
it 'has the same connection as Ci::ApplicationRecord' do
query = 'select current_database()'
expect(described_class.connection.execute(query).first).to eq(Ci::ApplicationRecord.connection.execute(query).first)
expect(described_class.retrieve_connection.execute(query).first).to eq(Ci::ApplicationRecord.retrieve_connection.execute(query).first)
end
it 'has the same sticking as Ci::ApplicationRecord' do
expect(described_class.sticking).to eq(Ci::ApplicationRecord.sticking)
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ActsAsTaggableOn::Tagging do
it 'has the same connection as Ci::ApplicationRecord' do
query = 'select current_database()'
expect(described_class.connection.execute(query).first).to eq(Ci::ApplicationRecord.connection.execute(query).first)
expect(described_class.retrieve_connection.execute(query).first).to eq(Ci::ApplicationRecord.retrieve_connection.execute(query).first)
end
it 'has the same sticking as Ci::ApplicationRecord' do
expect(described_class.sticking).to eq(Ci::ApplicationRecord.sticking)
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