diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 18:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 18:08:42 +0300 |
commit | c27acb1d376f7127cd33eadcc8f5683ed55262bc (patch) | |
tree | 685c31391dca71a73782b5c8626f4ef5b582dc21 /spec/migrations | |
parent | 1808454313ed75c92e1384466e8c83bfbc8ae25e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb b/spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb new file mode 100644 index 00000000000..5ff9ff4641f --- /dev/null +++ b/spec/migrations/schedule_update_existing_subgroup_to_match_visibility_level_of_parent_spec.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb') + +describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent, :migration, :sidekiq do + include MigrationHelpers::NamespacesHelpers + let(:migration_class) { described_class::MIGRATION } + let(:migration_name) { migration_class.to_s.demodulize } + + context 'private visibility level' do + it 'correctly schedules background migrations' do + parent = create_namespace('parent', Gitlab::VisibilityLevel::PRIVATE) + create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: parent.id) + + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(BackgroundMigrationWorker.jobs.size).to eq(1) + expect(migration_name).to be_scheduled_migration_with_multiple_args([parent.id], Gitlab::VisibilityLevel::PRIVATE) + end + end + end + + it 'correctly schedules background migrations for groups and subgroups' do + parent = create_namespace('parent', Gitlab::VisibilityLevel::PRIVATE) + middle_group = create_namespace('middle_group', Gitlab::VisibilityLevel::PRIVATE, parent_id: parent.id) + create_namespace('middle_empty_group', Gitlab::VisibilityLevel::PRIVATE, parent_id: parent.id) + create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id) + + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(BackgroundMigrationWorker.jobs.size).to eq(1) + expect(migration_name).to be_scheduled_migration_with_multiple_args([middle_group.id, parent.id], Gitlab::VisibilityLevel::PRIVATE) + end + end + end + end + + context 'internal visibility level' do + it 'correctly schedules background migrations' do + parent = create_namespace('parent', Gitlab::VisibilityLevel::INTERNAL) + middle_group = create_namespace('child', Gitlab::VisibilityLevel::INTERNAL, parent_id: parent.id) + create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id) + + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(BackgroundMigrationWorker.jobs.size).to eq(1) + expect(migration_name).to be_scheduled_migration_with_multiple_args([parent.id, middle_group.id], Gitlab::VisibilityLevel::INTERNAL) + end + end + end + end + + context 'mixed visibility levels' do + it 'correctly schedules background migrations' do + parent1 = create_namespace('parent1', Gitlab::VisibilityLevel::INTERNAL) + create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: parent1.id) + parent2 = create_namespace('parent2', Gitlab::VisibilityLevel::PRIVATE) + middle_group = create_namespace('middle_group', Gitlab::VisibilityLevel::INTERNAL, parent_id: parent2.id) + create_namespace('child', Gitlab::VisibilityLevel::PUBLIC, parent_id: middle_group.id) + + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(BackgroundMigrationWorker.jobs.size).to eq(2) + expect(migration_name).to be_scheduled_migration_with_multiple_args([parent1.id, middle_group.id], Gitlab::VisibilityLevel::INTERNAL) + expect(migration_name).to be_scheduled_migration_with_multiple_args([parent2.id], Gitlab::VisibilityLevel::PRIVATE) + end + end + end + end +end |