diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-13 12:11:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-13 12:11:55 +0300 |
commit | bc2f7ab125361e4180018b1b933f42a8709df356 (patch) | |
tree | cbdb7c268428bbf1bd1023cfd5865a530e91dc8f /spec/migrations | |
parent | 56a177ed56309f4742fe9f978adec394636bd7ca (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
2 files changed, 57 insertions, 0 deletions
diff --git a/spec/migrations/20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb b/spec/migrations/20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb new file mode 100644 index 00000000000..d07d9a71b06 --- /dev/null +++ b/spec/migrations/20211006060436_schedule_populate_topics_total_projects_count_cache_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration!('schedule_populate_topics_total_projects_count_cache') + +RSpec.describe SchedulePopulateTopicsTotalProjectsCountCache do + let(:topics) { table(:topics) } + let!(:topic_1) { topics.create!(name: 'Topic1') } + let!(:topic_2) { topics.create!(name: 'Topic2') } + let!(:topic_3) { topics.create!(name: 'Topic3') } + + describe '#up' do + before do + stub_const("#{described_class}::BATCH_SIZE", 2) + end + + it 'schedules BackfillProjectsWithCoverage background jobs', :aggregate_failures do + Sidekiq::Testing.fake! do + freeze_time do + migrate! + + expect(described_class::MIGRATION).to be_scheduled_delayed_migration(2.minutes, topic_1.id, topic_2.id) + expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, topic_3.id, topic_3.id) + expect(BackgroundMigrationWorker.jobs.size).to eq(2) + end + end + end + end +end diff --git a/spec/migrations/recreate_index_security_ci_builds_on_name_and_id_parser_features_spec.rb b/spec/migrations/recreate_index_security_ci_builds_on_name_and_id_parser_features_spec.rb new file mode 100644 index 00000000000..77824a743fb --- /dev/null +++ b/spec/migrations/recreate_index_security_ci_builds_on_name_and_id_parser_features_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_migration! + +RSpec.describe RecreateIndexSecurityCiBuildsOnNameAndIdParserFeatures, :migration do + let(:db) { described_class.new } + let(:pg_class) { table(:pg_class) } + let(:pg_index) { table(:pg_index) } + let(:async_indexes) { table(:postgres_async_indexes) } + + it "recreates index" do + reversible_migration do |migration| + migration.before -> { + expect(async_indexes.where(name: described_class::OLD_INDEX_NAME).exists?).to be false + expect(db.index_exists?(described_class::TABLE, described_class::COLUMNS, name: described_class::OLD_INDEX_NAME)).to be true + expect(db.index_exists?(described_class::TABLE, described_class::COLUMNS, name: described_class::NEW_INDEX_NAME)).to be false + } + + migration.after -> { + expect(async_indexes.where(name: described_class::OLD_INDEX_NAME).exists?).to be true + expect(db.index_exists?(described_class::TABLE, described_class::COLUMNS, name: described_class::OLD_INDEX_NAME)).to be false + expect(db.index_exists?(described_class::TABLE, described_class::COLUMNS, name: described_class::NEW_INDEX_NAME)).to be true + } + end + end +end |