diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/migrations/move_container_registry_enabled_to_project_features_spec.rb | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) | |
download | gitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/migrations/move_container_registry_enabled_to_project_features_spec.rb')
-rw-r--r-- | spec/migrations/move_container_registry_enabled_to_project_features_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/migrations/move_container_registry_enabled_to_project_features_spec.rb b/spec/migrations/move_container_registry_enabled_to_project_features_spec.rb new file mode 100644 index 00000000000..c7b07f3ef37 --- /dev/null +++ b/spec/migrations/move_container_registry_enabled_to_project_features_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20210226120851_move_container_registry_enabled_to_project_features.rb') + +RSpec.describe MoveContainerRegistryEnabledToProjectFeatures, :migration do + let(:namespace) { table(:namespaces).create!(name: 'gitlab', path: 'gitlab-org') } + + let!(:projects) do + [ + table(:projects).create!(namespace_id: namespace.id, name: 'project 1'), + table(:projects).create!(namespace_id: namespace.id, name: 'project 2'), + table(:projects).create!(namespace_id: namespace.id, name: 'project 3'), + table(:projects).create!(namespace_id: namespace.id, name: 'project 4') + ] + end + + before do + stub_const("#{described_class.name}::BATCH_SIZE", 3) + end + + around do |example| + Sidekiq::Testing.fake! do + freeze_time do + example.call + end + end + end + + it 'schedules jobs for ranges of projects' do + migrate! + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(2.minutes, projects[0].id, projects[2].id) + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(4.minutes, projects[3].id, projects[3].id) + end + + it 'schedules jobs according to the configured batch size' do + expect { migrate! }.to change { BackgroundMigrationWorker.jobs.size }.by(2) + end +end |