diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy_spec.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy_spec.rb')
-rw-r--r-- | spec/lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy_spec.rb | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/spec/lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy_spec.rb b/spec/lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy_spec.rb index 9fdd7bf8adc..37fdd209622 100644 --- a/spec/lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy_spec.rb +++ b/spec/lib/gitlab/background_migration/batching_strategies/primary_key_batching_strategy_spec.rb @@ -60,26 +60,21 @@ RSpec.describe Gitlab::BackgroundMigration::BatchingStrategies::PrimaryKeyBatchi expect(batch_bounds).to eq([namespace4.id, namespace4.id]) end - end - - context 'additional filters' do - let(:strategy_with_filters) do - Class.new(described_class) do - def apply_additional_filters(relation, job_arguments:, job_class: nil) - min_id = job_arguments.first - relation.where.not(type: 'Project').where('id >= ?', min_id) + context 'when scope has a join which makes the column name ambiguous' do + let(:job_class) do + Class.new(Gitlab::BackgroundMigration::BatchedMigrationJob) do + scope_to ->(r) { r.joins('LEFT JOIN users ON users.id = namespaces.owner_id') } end end - end - let(:batching_strategy) { strategy_with_filters.new(connection: ActiveRecord::Base.connection) } - let!(:namespace5) { namespaces.create!(name: 'batchtest5', path: 'batch-test5', type: 'Project') } + it 'executes the correct query' do + expect(job_class).to receive(:generic_instance).and_call_original - it 'applies additional filters' do - batch_bounds = batching_strategy.next_batch(:namespaces, :id, batch_min_value: namespace4.id, batch_size: 3, job_arguments: [1]) + batch_bounds = batching_strategy.next_batch(:namespaces, :id, batch_min_value: namespace4.id, batch_size: 3, job_arguments: [], job_class: job_class) - expect(batch_bounds).to eq([namespace4.id, namespace4.id]) + expect(batch_bounds).to eq([namespace4.id, namespace4.id]) + end end end end |