diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 15:09:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-12 15:09:39 +0300 |
commit | f81141c25d0dd79de8c07559bf268cb6e0d287d3 (patch) | |
tree | a0f700b90845f738cc2037cbbfb7a980c36137ac /spec/migrations/backfill_issues_upvotes_count_spec.rb | |
parent | 12de063de4663766a43d6c3e0883a686d66ab401 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations/backfill_issues_upvotes_count_spec.rb')
-rw-r--r-- | spec/migrations/backfill_issues_upvotes_count_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/migrations/backfill_issues_upvotes_count_spec.rb b/spec/migrations/backfill_issues_upvotes_count_spec.rb new file mode 100644 index 00000000000..f2bea0edea0 --- /dev/null +++ b/spec/migrations/backfill_issues_upvotes_count_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe BackfillIssuesUpvotesCount do + let(:migration) { described_class.new } + let(:issues) { table(:issues) } + let(:award_emoji) { table(:award_emoji) } + + let!(:issue1) { issues.create! } + let!(:issue2) { issues.create! } + let!(:issue3) { issues.create! } + let!(:issue4) { issues.create! } + let!(:issue4_without_thumbsup) { issues.create! } + + let!(:award_emoji1) { award_emoji.create!( name: 'thumbsup', awardable_type: 'Issue', awardable_id: issue1.id) } + let!(:award_emoji2) { award_emoji.create!( name: 'thumbsup', awardable_type: 'Issue', awardable_id: issue2.id) } + let!(:award_emoji3) { award_emoji.create!( name: 'thumbsup', awardable_type: 'Issue', awardable_id: issue3.id) } + let!(:award_emoji4) { award_emoji.create!( name: 'thumbsup', awardable_type: 'Issue', awardable_id: issue4.id) } + + it 'correctly schedules background migrations' do + stub_const("#{described_class.name}::BATCH_SIZE", 2) + + Sidekiq::Testing.fake! do + freeze_time do + migrate! + + expect(described_class::MIGRATION).to be_scheduled_migration(issue1.id, issue2.id) + expect(described_class::MIGRATION).to be_scheduled_migration(issue3.id, issue4.id) + expect(BackgroundMigrationWorker.jobs.size).to eq(2) + end + end + end +end |