diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 00:14:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 00:14:54 +0300 |
commit | e7cbe1006f44085b49e2673f87fed00f5cc44cc8 (patch) | |
tree | 2b197eb55a8fcc7f23171492b5e5fae766193e81 /spec/workers/loose_foreign_keys | |
parent | d738ba980c5ce598811b700e215ab957132f3a67 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/loose_foreign_keys')
-rw-r--r-- | spec/workers/loose_foreign_keys/cleanup_worker_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb b/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb index 3c628d036ff..497f95cf34d 100644 --- a/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb +++ b/spec/workers/loose_foreign_keys/cleanup_worker_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe LooseForeignKeys::CleanupWorker do include MigrationsHelpers + using RSpec::Parameterized::TableSyntax def create_table_structure migration = ActiveRecord::Migration.new.extend(Gitlab::Database::MigrationHelpers::LooseForeignKeyHelpers) @@ -149,4 +150,31 @@ RSpec.describe LooseForeignKeys::CleanupWorker do expect { described_class.new.perform }.not_to change { LooseForeignKeys::DeletedRecord.status_processed.count } end end + + describe 'multi-database support' do + where(:current_minute, :configured_base_models, :expected_connection) do + 2 | { main: ApplicationRecord, ci: Ci::ApplicationRecord } | ApplicationRecord.connection + 3 | { main: ApplicationRecord, ci: Ci::ApplicationRecord } | Ci::ApplicationRecord.connection + 2 | { main: ApplicationRecord } | ApplicationRecord.connection + 3 | { main: ApplicationRecord } | ApplicationRecord.connection + end + + with_them do + before do + allow(Gitlab::Database).to receive(:database_base_models).and_return(configured_base_models) + end + + it 'uses the correct connection' do + LooseForeignKeys::DeletedRecord.count.times do + expect_next_found_instance_of(LooseForeignKeys::DeletedRecord) do |instance| + expect(instance.class.connection).to eq(expected_connection) + end + end + + travel_to DateTime.new(2019, 1, 1, 10, current_minute) do + described_class.new.perform + end + end + end + end end |