Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20220502015011_clean_up_fix_merge_request_diff_commit_users_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 769c0993b6782ca6d5976c689fde5d2b9d6ee955 (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
# frozen_string_literal: true

require 'spec_helper'
require_migration! 'clean_up_fix_merge_request_diff_commit_users'

RSpec.describe CleanUpFixMergeRequestDiffCommitUsers, :migration do
  let(:namespaces) { table(:namespaces) }
  let(:projects) { table(:projects) }
  let(:project_namespace) { namespaces.create!(name: 'project2', path: 'project2', type: 'Project') }
  let(:namespace) { namespaces.create!(name: 'foo', path: 'foo') }

  describe '#up' do
    it 'finalizes the background migration' do
      expect(described_class).to be_finalize_background_migration_of('FixMergeRequestDiffCommitUsers')

      migrate!
    end

    it 'processes pending background jobs' do
      project = projects.create!(name: 'p1', namespace_id: namespace.id, project_namespace_id: project_namespace.id)

      Gitlab::Database::BackgroundMigrationJob.create!(
        class_name: 'FixMergeRequestDiffCommitUsers',
        arguments: [project.id]
      )

      migrate!

      background_migrations = Gitlab::Database::BackgroundMigrationJob
        .where(class_name: 'FixMergeRequestDiffCommitUsers')

      expect(background_migrations.count).to eq(0)
    end
  end
end