summaryrefslogtreecommitdiff
path: root/spec/lib/bitbucket/page_spec.rb
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-16 23:25:14 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-16 23:25:14 +0000
commita22be3065dc9c80d3a18ca81eda480b9c39e35a6 (patch)
treed29fc79464dbf3f1fd09d034a4b73c8eb230a9e3 /spec/lib/bitbucket/page_spec.rb
parent12a7e717d7b9fdd265d54a9c5bd07394e304b187 (diff)
parenta3be4aeb7a71cc940394a5f13d09e79fcafdb1d5 (diff)
downloadgitlab-ce-a22be3065dc9c80d3a18ca81eda480b9c39e35a6.tar.gz
Merge branch 'bitbucket-oauth2' into 'master'
Refactor Bitbucket importer to use BitBucket API Version 2 ## What does this MR do? ## Are there points in the code the reviewer needs to double check? ## Why was this MR needed? ## What are the relevant issue numbers? https://gitlab.com/gitlab-org/gitlab-ce/issues/19946 ## Screenshots (if relevant) This MR needs the following permissions in the Bitbucket OAuth settings: ![image](/uploads/a26ae5e430a724bf581a92da7028ce3c/image.png) - [] ## Does this MR meet the acceptance criteria? - [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [ ] API support added - Tests - [ ] Added for this feature/bug - [ ] All builds are passing - [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5995
Diffstat (limited to 'spec/lib/bitbucket/page_spec.rb')
-rw-r--r--spec/lib/bitbucket/page_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/lib/bitbucket/page_spec.rb b/spec/lib/bitbucket/page_spec.rb
new file mode 100644
index 00000000000..04d5a0470b1
--- /dev/null
+++ b/spec/lib/bitbucket/page_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper'
+
+describe Bitbucket::Page do
+ let(:response) { { 'values' => [{ 'username' => 'Ben' }], 'pagelen' => 2, 'next' => '' } }
+
+ before do
+ # Autoloading hack
+ Bitbucket::Representation::User.new({})
+ end
+
+ describe '#items' do
+ it 'returns collection of needed objects' do
+ page = described_class.new(response, :user)
+
+ expect(page.items.first).to be_a(Bitbucket::Representation::User)
+ expect(page.items.count).to eq(1)
+ end
+ end
+
+ describe '#attrs' do
+ it 'returns attributes' do
+ page = described_class.new(response, :user)
+
+ expect(page.attrs.keys).to include(:pagelen, :next)
+ end
+ end
+
+ describe '#next?' do
+ it 'returns true' do
+ page = described_class.new(response, :user)
+
+ expect(page.next?).to be_truthy
+ end
+
+ it 'returns false' do
+ response['next'] = nil
+ page = described_class.new(response, :user)
+
+ expect(page.next?).to be_falsey
+ end
+ end
+
+ describe '#next' do
+ it 'returns next attribute' do
+ page = described_class.new(response, :user)
+
+ expect(page.next).to eq('')
+ end
+ end
+end