Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-01-07 08:09:41 +0300
committerStan Hu <stanhu@gmail.com>2019-01-07 08:13:00 +0300
commita06b7a7d5d6012b3f89ddaab5189a85f5cc49c14 (patch)
treec49fd3f45ea5b7fafc7ad14312e41658edb453db /spec/lib
parentd432d674148601555c4ba693bb7c282ac9fe3d4a (diff)
Fix Bitbucket Server import only including first 25 pull requests
The change to paginate repos in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22825 caused the paginator to stop after 25 pull requests because the limit was set to 25 if none was defined. To fix this, we should only stop if the limit has actually been set and use the limit parameter to determine the maximum number of items to process per page. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55914
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/bitbucket_server/paginator_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/lib/bitbucket_server/paginator_spec.rb b/spec/lib/bitbucket_server/paginator_spec.rb
index d268d4f23cf..eadd7f68bfb 100644
--- a/spec/lib/bitbucket_server/paginator_spec.rb
+++ b/spec/lib/bitbucket_server/paginator_spec.rb
@@ -30,6 +30,17 @@ describe BitbucketServer::Paginator do
expect { limited.items }.to raise_error(StopIteration)
end
+ it 'does not stop if limit is unspecified' do
+ stub_const("BitbucketServer::Paginator::PAGE_LENGTH", 1)
+ paginator = described_class.new(connection, 'http://more-data', :pull_request, page_offset: 0, limit: nil)
+ allow(paginator).to receive(:fetch_next_page).and_return(first_page, last_page)
+
+ expect(paginator.has_next_page?).to be_truthy
+ expect(paginator.items).to match(['item_1'])
+ expect(paginator.has_next_page?).to be_truthy
+ expect(paginator.items).to match(['item_2'])
+ 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)