diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-13 22:27:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-13 22:27:03 +0300 |
commit | 7f5f940041c8d1ee074be96cc64bdccdd95649b1 (patch) | |
tree | 334342b5d7c1898efcbe345c51838b63aa5106bc /spec/migrations/ensure_namespace_settings_creation_spec.rb | |
parent | b16db1458f5e0f6b0427cf3e2471302657297427 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.4
Diffstat (limited to 'spec/migrations/ensure_namespace_settings_creation_spec.rb')
-rw-r--r-- | spec/migrations/ensure_namespace_settings_creation_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/migrations/ensure_namespace_settings_creation_spec.rb b/spec/migrations/ensure_namespace_settings_creation_spec.rb new file mode 100644 index 00000000000..8574063f7fe --- /dev/null +++ b/spec/migrations/ensure_namespace_settings_creation_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20201104124300_ensure_namespace_settings_creation.rb') + +RSpec.describe EnsureNamespaceSettingsCreation do + context 'when there are namespaces without namespace settings' do + let(:namespaces) { table(:namespaces) } + let(:namespace_settings) { table(:namespace_settings) } + let!(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') } + let!(:namespace_2) { namespaces.create!(name: 'gitlab', path: 'gitlab-org2') } + + it 'migrates namespaces without namespace_settings' do + stub_const("#{described_class.name}::BATCH_SIZE", 2) + + Sidekiq::Testing.fake! do + freeze_time do + migrate! + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(2.minutes.to_i, namespace.id, namespace_2.id) + end + end + end + + it 'schedules migrations in batches ' do + stub_const("#{described_class.name}::BATCH_SIZE", 2) + + namespace_3 = namespaces.create!(name: 'gitlab', path: 'gitlab-org3') + namespace_4 = namespaces.create!(name: 'gitlab', path: 'gitlab-org4') + + Sidekiq::Testing.fake! do + freeze_time do + migrate! + + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(2.minutes.to_i, namespace.id, namespace_2.id) + expect(described_class::MIGRATION) + .to be_scheduled_delayed_migration(4.minutes.to_i, namespace_3.id, namespace_4.id) + end + end + end + end +end |