summaryrefslogtreecommitdiff
path: root/spec/lib/bitbucket_server/paginator_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-11-05 15:37:21 -0800
committerStan Hu <stanhu@gmail.com>2018-11-07 11:37:46 -0800
commit5b6d5301d9589b694fea0820a2b6cf165642669b (patch)
tree50a3cfa2afc1b9fb6783cb15d9582d3a429480b0 /spec/lib/bitbucket_server/paginator_spec.rb
parent4068d46078faaa97acbfbe33cc7663db6d1c831a (diff)
downloadgitlab-ce-5b6d5301d9589b694fea0820a2b6cf165642669b.tar.gz
Paginate Bitbucket Server importer projects
To prevent delays in loading the page and reduce memory usage, limit the number of projects shown at 25 per page. Part of https://gitlab.com/gitlab-org/gitlab-ce/issues/50021
Diffstat (limited to 'spec/lib/bitbucket_server/paginator_spec.rb')
-rw-r--r--spec/lib/bitbucket_server/paginator_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/lib/bitbucket_server/paginator_spec.rb b/spec/lib/bitbucket_server/paginator_spec.rb
index 2de50eba3c4..d268d4f23cf 100644
--- a/spec/lib/bitbucket_server/paginator_spec.rb
+++ b/spec/lib/bitbucket_server/paginator_spec.rb
@@ -20,6 +20,16 @@ describe BitbucketServer::Paginator do
expect { paginator.items }.to raise_error(StopIteration)
end
+ it 'obeys limits' do
+ limited = described_class.new(connection, 'http://more-data', :pull_request, page_offset: 0, limit: 1)
+ allow(limited).to receive(:fetch_next_page).and_return(first_page)
+
+ expect(limited.has_next_page?).to be_truthy
+ expect(limited.items).to match(['item_1'])
+ expect(limited.has_next_page?).to be_truthy
+ expect { limited.items }.to raise_error(StopIteration)
+ end
+
it 'calls the connection with different offsets' do
expect(connection).to receive(:get).with('http://more-data', start: 0, limit: BitbucketServer::Paginator::PAGE_LENGTH).and_return(page_attrs)