diff options
author | Igor Drozdov <idrozdov@gitlab.com> | 2019-07-02 17:42:58 +0300 |
---|---|---|
committer | Igor Drozdov <idrozdov@gitlab.com> | 2019-07-09 12:13:55 +0300 |
commit | 184807b253991bc0aed20cad038c6d6602b5dba8 (patch) | |
tree | fd6f78064cb5926a65a8892e352464c47fb64d64 /spec | |
parent | 775910d3726007c94c74e49f3f243464e50d65f0 (diff) | |
download | gitlab-ce-184807b253991bc0aed20cad038c6d6602b5dba8.tar.gz |
Add cleanup migration for MR's mutliple assigneesid-clean-up-mr-assignees-migration
The migration steals the remaining background jobs
of populating MRs with assignees, executes them
synchronously and then makes sure that all the
assignees are migrated
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/background_migration/populate_merge_request_assignees_table_spec.rb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/spec/lib/gitlab/background_migration/populate_merge_request_assignees_table_spec.rb b/spec/lib/gitlab/background_migration/populate_merge_request_assignees_table_spec.rb index 4a81a37d341..ad4fa4fe03a 100644 --- a/spec/lib/gitlab/background_migration/populate_merge_request_assignees_table_spec.rb +++ b/spec/lib/gitlab/background_migration/populate_merge_request_assignees_table_spec.rb @@ -27,14 +27,19 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestAssigneesTable, :migra merge_requests.create(params) end + before do + create_merge_request(2, assignee_id: user.id) + create_merge_request(3, assignee_id: user_2.id) + create_merge_request(4, assignee_id: user_3.id) + + # Test filtering MRs without assignees + create_merge_request(5, assignee_id: nil) + # Test filtering already migrated row + merge_request_assignees.create!(merge_request_id: 2, user_id: user_3.id) + end + describe '#perform' do it 'creates merge_request_assignees rows according to merge_requests' do - create_merge_request(2, assignee_id: user.id) - create_merge_request(3, assignee_id: user_2.id) - create_merge_request(4, assignee_id: user_3.id) - # Test filtering already migrated row - merge_request_assignees.create!(merge_request_id: 2, user_id: user_3.id) - subject.perform(1, 4) rows = merge_request_assignees.order(:id).map { |row| row.attributes.slice('merge_request_id', 'user_id') } @@ -53,4 +58,13 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestAssigneesTable, :migra end end end + + describe '#perform_all_sync' do + it 'executes peform for all merge requests in batches' do + expect(subject).to receive(:perform).with(2, 4).ordered + expect(subject).to receive(:perform).with(5, 5).ordered + + subject.perform_all_sync(batch_size: 3) + end + end end |