summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb
blob: 20f3270526e158578a577905ecd579686dca9b4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

RSpec.shared_examples 'marks background migration job records' do
  it 'marks each job record as succeeded after processing' do
    create(:background_migration_job, class_name: "::#{described_class.name}",
           arguments: arguments)

    expect(::Gitlab::Database::BackgroundMigrationJob).to receive(:mark_all_as_succeeded).and_call_original

    expect do
      subject.perform(*arguments)
    end.to change { ::Gitlab::Database::BackgroundMigrationJob.succeeded.count }.from(0).to(1)
  end

  it 'returns the number of job records marked as succeeded' do
    create(:background_migration_job, class_name: "::#{described_class.name}",
           arguments: arguments)

    jobs_updated = subject.perform(*arguments)

    expect(jobs_updated).to eq(1)
  end
end