blob: f627ea825b31bc3111be58dfcdc1fffed9babb9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# frozen_string_literal: true
require 'spec_helper'
require_migration! 'clean_up_migrate_merge_request_diff_commit_users'
RSpec.describe CleanUpMigrateMergeRequestDiffCommitUsers, :migration, feature_category: :code_review do
describe '#up' do
context 'when there are pending jobs' do
it 'processes the jobs immediately' do
Gitlab::Database::BackgroundMigrationJob.create!(
class_name: 'MigrateMergeRequestDiffCommitUsers',
status: :pending,
arguments: [10, 20]
)
spy = Gitlab::BackgroundMigration::MigrateMergeRequestDiffCommitUsers
migration = described_class.new
allow(Gitlab::BackgroundMigration::MigrateMergeRequestDiffCommitUsers)
.to receive(:new)
.and_return(spy)
expect(migration).to receive(:say)
expect(spy).to receive(:perform).with(10, 20)
migration.up
end
end
context 'when all jobs are completed' do
it 'does nothing' do
Gitlab::Database::BackgroundMigrationJob.create!(
class_name: 'MigrateMergeRequestDiffCommitUsers',
status: :succeeded,
arguments: [10, 20]
)
migration = described_class.new
expect(migration).not_to receive(:say)
expect(Gitlab::BackgroundMigration::MigrateMergeRequestDiffCommitUsers)
.not_to receive(:new)
migration.up
end
end
end
end
|