summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2018-02-08 10:08:55 -0800
committerMichael Kozono <mkozono@gmail.com>2018-02-14 12:58:56 -0800
commit0472147942162cca8e9d130c3ba5b6fe4cf4556b (patch)
tree08da2086b0994e87e46ea4ee147c0980552902d9
parentbf7412e48e47c31fe70046285c6109f6a2bb23c5 (diff)
downloadgitlab-ce-0472147942162cca8e9d130c3ba5b6fe4cf4556b.tar.gz
Fix last batch size equals max batch size error
-rw-r--r--lib/gitlab/background_migration/prepare_untracked_uploads.rb2
-rw-r--r--spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb24
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/gitlab/background_migration/prepare_untracked_uploads.rb b/lib/gitlab/background_migration/prepare_untracked_uploads.rb
index 476c46341ae..71d6e2e435d 100644
--- a/lib/gitlab/background_migration/prepare_untracked_uploads.rb
+++ b/lib/gitlab/background_migration/prepare_untracked_uploads.rb
@@ -88,7 +88,7 @@ module Gitlab
end
end
- yield(paths)
+ yield(paths) if paths.any?
end
def build_find_command(search_dir)
diff --git a/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
index 8bb9ebe0419..2d0a63dbd62 100644
--- a/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
+++ b/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
@@ -128,6 +128,18 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
expect(untracked_files_for_uploads.count).to eq(5)
end
end
+
+ context 'when the last batch size exactly matches the max batch size' do
+ it 'does not raise error' do
+ stub_const("#{described_class}::FIND_BATCH_SIZE", 5)
+
+ expect do
+ described_class.new.perform
+ end.not_to raise_error
+
+ expect(untracked_files_for_uploads.count).to eq(5)
+ end
+ end
end
end
@@ -216,6 +228,18 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
expect(untracked_files_for_uploads.count).to eq(5)
end
end
+
+ context 'when the last batch size exactly matches the max batch size' do
+ it 'does not raise error' do
+ stub_const("#{described_class}::FIND_BATCH_SIZE", 5)
+
+ expect do
+ described_class.new.perform
+ end.not_to raise_error
+
+ expect(untracked_files_for_uploads.count).to eq(5)
+ end
+ end
end
end