summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-11-07 20:38:17 -0800
committerMichael Kozono <mkozono@gmail.com>2017-12-01 15:26:40 -0800
commit13e0ee373573c41d4c1d095fbeec2a133ae626bb (patch)
treeba089c507ef3bbd2527298e5dc854d174fd3ff21 /spec
parent3dc74378ec54afb4b15d9f1bdf3781ddd50f83e3 (diff)
downloadgitlab-ce-13e0ee373573c41d4c1d095fbeec2a133ae626bb.tar.gz
Test batch processing
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
index c61a207d012..5446edae06f 100644
--- a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
@@ -53,6 +53,12 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, :sid
expect(appearance.uploads.count).to eq(2)
end
+ it 'sets all added or confirmed tracked files to tracked' do
+ expect do
+ described_class.new.perform(1, 1000)
+ end.to change { unhashed_upload_files.where(tracked: true).count }.from(0).to(8)
+ end
+
it 'does not create duplicate uploads of already tracked files' do
described_class.new.perform(1, 1000)
@@ -60,6 +66,42 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, :sid
expect(project1.uploads.count).to eq(2)
expect(appearance.uploads.count).to eq(2)
end
+
+ it 'uses the start and end batch ids [only 1st half]' do
+ start_id = unhashed_upload_files.all.to_a[0].id
+ end_id = unhashed_upload_files.all.to_a[3].id
+
+ expect do
+ described_class.new.perform(start_id, end_id)
+ end.to change { uploads.count }.from(4).to(6)
+
+ expect(user1.uploads.count).to eq(1)
+ expect(user2.uploads.count).to eq(1)
+ expect(appearance.uploads.count).to eq(2)
+ expect(project1.uploads.count).to eq(2)
+ expect(project2.uploads.count).to eq(0)
+
+ # Only 4 have been either confirmed or added to uploads
+ expect(unhashed_upload_files.where(tracked: true).count).to eq(4)
+ end
+
+ it 'uses the start and end batch ids [only 2nd half]' do
+ start_id = unhashed_upload_files.all.to_a[4].id
+ end_id = unhashed_upload_files.all.to_a[7].id
+
+ expect do
+ described_class.new.perform(start_id, end_id)
+ end.to change { uploads.count }.from(4).to(6)
+
+ expect(user1.uploads.count).to eq(1)
+ expect(user2.uploads.count).to eq(0)
+ expect(appearance.uploads.count).to eq(1)
+ expect(project1.uploads.count).to eq(2)
+ expect(project2.uploads.count).to eq(2)
+
+ # Only 4 have been either confirmed or added to uploads
+ expect(unhashed_upload_files.where(tracked: true).count).to eq(4)
+ end
end
context 'with no untracked files' do