diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb')
-rw-r--r-- | spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb b/spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb new file mode 100644 index 00000000000..d7aa53ec35b --- /dev/null +++ b/spec/migrations/20221215151822_schedule_backfill_releases_author_id_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe ScheduleBackfillReleasesAuthorId, feature_category: :release_orchestration do + context 'when there are releases without author' do + let(:releases_table) { table(:releases) } + let(:user_table) { table(:users) } + let(:date_time) { DateTime.now } + let!(:batched_migration) { described_class::MIGRATION } + let!(:test_user) do + user_table.create!(name: 'test', + email: 'test@example.com', + username: 'test', + projects_limit: 10) + end + + before do + releases_table.create!(tag: 'tag1', name: 'tag1', + released_at: (date_time - 1.minute), author_id: test_user.id) + releases_table.create!(tag: 'tag2', name: 'tag2', + released_at: (date_time - 2.minutes), author_id: test_user.id) + releases_table.new(tag: 'tag3', name: 'tag3', + released_at: (date_time - 3.minutes), author_id: nil).save!(validate: false) + releases_table.new(tag: 'tag4', name: 'tag4', + released_at: (date_time - 4.minutes), author_id: nil).save!(validate: false) + end + + it 'schedules a new batched migration' do + reversible_migration do |migration| + migration.before -> { + expect(batched_migration).not_to have_scheduled_batched_migration + } + + migration.after -> { + expect(batched_migration).to have_scheduled_batched_migration( + table_name: :releases, + column_name: :id, + interval: described_class::JOB_DELAY_INTERVAL, + job_arguments: [User.find_by(user_type: :ghost)&.id] + ) + } + end + end + end + + context 'when there are no releases without author' do + it 'does not schedule batched migration' do + expect(described_class.new.up).not_to have_scheduled_batched_migration + end + end +end |