blob: 6511f554436955a897517200bd68482616ee46bd (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# frozen_string_literal: true
require 'spec_helper'
require_migration! 'schedule_fix_merge_request_diff_commit_users_migration'
RSpec.describe ScheduleFixMergeRequestDiffCommitUsersMigration, :migration do
let(:migration) { described_class.new }
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
let(:namespace) { namespaces.create!(name: 'foo', path: 'foo') }
describe '#up' do
it 'does nothing when there are no projects to correct' do
migration.up
expect(Gitlab::Database::BackgroundMigrationJob.count).to be_zero
end
it 'schedules imported projects created after July' do
project = projects.create!(
namespace_id: namespace.id,
import_type: 'gitlab_project',
created_at: '2021-08-01'
)
expect(migration)
.to receive(:migrate_in)
.with(2.minutes, 'FixMergeRequestDiffCommitUsers', [project.id])
migration.up
expect(Gitlab::Database::BackgroundMigrationJob.count).to eq(1)
job = Gitlab::Database::BackgroundMigrationJob.first
expect(job.class_name).to eq('FixMergeRequestDiffCommitUsers')
expect(job.arguments).to eq([project.id])
end
it 'ignores projects imported before July' do
projects.create!(
namespace_id: namespace.id,
import_type: 'gitlab_project',
created_at: '2020-08-01'
)
migration.up
expect(Gitlab::Database::BackgroundMigrationJob.count).to be_zero
end
it 'ignores projects that are not imported' do
projects.create!(
namespace_id: namespace.id,
created_at: '2021-08-01'
)
migration.up
expect(Gitlab::Database::BackgroundMigrationJob.count).to be_zero
end
end
end
|