diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/lib/gitlab/looping_batcher_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/lib/gitlab/looping_batcher_spec.rb')
-rw-r--r-- | spec/lib/gitlab/looping_batcher_spec.rb | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/spec/lib/gitlab/looping_batcher_spec.rb b/spec/lib/gitlab/looping_batcher_spec.rb deleted file mode 100644 index b03e969c1e7..00000000000 --- a/spec/lib/gitlab/looping_batcher_spec.rb +++ /dev/null @@ -1,71 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe Gitlab::LoopingBatcher, :use_clean_rails_memory_store_caching do - describe '#next_range!' do - let(:model_class) { LfsObject } - let(:key) { 'looping_batcher_spec' } - let(:batch_size) { 2 } - - subject { described_class.new(model_class, key: key, batch_size: batch_size).next_range! } - - context 'when there are no records' do - it { is_expected.to be_nil } - end - - context 'when there are records' do - let!(:records) { create_list(model_class.underscore, 3) } - - context 'when it has never been called before' do - it { is_expected.to be_a Range } - - it 'starts from the beginning' do - expect(subject.first).to eq(1) - end - - it 'ends at a full batch' do - expect(subject.last).to eq(records.second.id) - end - - context 'when the batch size is greater than the number of records' do - let(:batch_size) { 5 } - - it 'ends at the last ID' do - expect(subject.last).to eq(records.last.id) - end - end - end - - context 'when it was called before' do - context 'when the previous batch included the end of the table' do - before do - described_class.new(model_class, key: key, batch_size: model_class.count).next_range! - end - - it 'starts from the beginning' do - expect(subject).to eq(1..records.second.id) - end - end - - context 'when the previous batch did not include the end of the table' do - before do - described_class.new(model_class, key: key, batch_size: model_class.count - 1).next_range! - end - - it 'starts after the previous batch' do - expect(subject).to eq(records.last.id..records.last.id) - end - end - - context 'if cache is cleared' do - it 'starts from the beginning' do - Rails.cache.clear - - expect(subject).to eq(1..records.second.id) - end - end - end - end - end -end |