diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/migrations/schedule_security_setting_creation_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/migrations/schedule_security_setting_creation_spec.rb')
-rw-r--r-- | spec/migrations/schedule_security_setting_creation_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/migrations/schedule_security_setting_creation_spec.rb b/spec/migrations/schedule_security_setting_creation_spec.rb new file mode 100644 index 00000000000..e1b7b540d7f --- /dev/null +++ b/spec/migrations/schedule_security_setting_creation_spec.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe ScheduleSecuritySettingCreation, :sidekiq do + describe '#up' do + let(:projects) { table(:projects) } + let(:namespaces) { table(:namespaces) } + + context 'for EE version' do + before do + stub_const("#{described_class.name}::BATCH_SIZE", 2) + allow(Gitlab).to receive(:ee?).and_return(true) + end + + it 'schedules background migration job' do + namespace = namespaces.create!(name: 'test', path: 'test') + projects.create!(id: 12, namespace_id: namespace.id, name: 'red', path: 'red') + projects.create!(id: 13, namespace_id: namespace.id, name: 'green', path: 'green') + projects.create!(id: 14, namespace_id: namespace.id, name: 'blue', path: 'blue') + + Sidekiq::Testing.fake! do + freeze_time do + migrate! + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(5.minutes, 12, 13) + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(10.minutes, 14, 14) + + expect(BackgroundMigrationWorker.jobs.size).to eq(2) + end + end + end + end + + context 'for FOSS version' do + before do + allow(Gitlab).to receive(:ee?).and_return(false) + end + + it 'does not schedule any jobs' do + namespace = namespaces.create!(name: 'test', path: 'test') + projects.create!(id: 12, namespace_id: namespace.id, name: 'red', path: 'red') + + Sidekiq::Testing.fake! do + freeze_time do + migrate! + + expect(BackgroundMigrationWorker.jobs.size).to eq(0) + end + end + end + end + end +end |