diff --git a/lib/bitbucket/paginator.rb b/lib/bitbucket/paginator.rb index b38cd99855c7a4a8fb3eb1c2fc4f5c8507bc3f4b..135d0d556743f658cfa54a05126cfe5f606e5f5c 100644 --- a/lib/bitbucket/paginator.rb +++ b/lib/bitbucket/paginator.rb @@ -29,7 +29,7 @@ module Bitbucket end def fetch_next_page - parsed_response = connection.get(next_url, { pagelen: PAGE_LENGTH, sort: :created_on }) + parsed_response = connection.get(next_url, pagelen: PAGE_LENGTH, sort: :created_on) Page.new(parsed_response, type) end end diff --git a/spec/lib/bitbucket/collection_spec.rb b/spec/lib/bitbucket/collection_spec.rb index eeed61b0488cc092de00fcc100f6f5bdd0285cae..015a7f80e03441d932696ff7f530c5e37f698d96 100644 --- a/spec/lib/bitbucket/collection_spec.rb +++ b/spec/lib/bitbucket/collection_spec.rb @@ -18,6 +18,7 @@ end describe Bitbucket::Collection do it "iterates paginator" do collection = described_class.new(TestPaginator.new) + expect(collection.to_a).to match(["result_1_page_1", "result_2_page_1", "result_1_page_2", "result_2_page_2"]) end end diff --git a/spec/lib/bitbucket/connection_spec.rb b/spec/lib/bitbucket/connection_spec.rb index 5242c6fac343e1c4d4f7f87595289c787868cc9f..6be681a8b47c95dee79dcf4263756fa8367c89b4 100644 --- a/spec/lib/bitbucket/connection_spec.rb +++ b/spec/lib/bitbucket/connection_spec.rb @@ -4,7 +4,9 @@ describe Bitbucket::Connection do describe '#get' do it 'calls OAuth2::AccessToken::get' do expect_any_instance_of(OAuth2::AccessToken).to receive(:get).and_return(double(parsed: true)) + connection = described_class.new({}) + connection.get('/users') end end @@ -12,6 +14,7 @@ describe Bitbucket::Connection do describe '#expired?' do it 'calls connection.expired?' do expect_any_instance_of(OAuth2::AccessToken).to receive(:expired?).and_return(true) + expect(described_class.new({}).expired?).to be_truthy end end @@ -19,7 +22,9 @@ describe Bitbucket::Connection do describe '#refresh!' do it 'calls connection.refresh!' do response = double(token: nil, expires_at: nil, expires_in: nil, refresh_token: nil) + expect_any_instance_of(OAuth2::AccessToken).to receive(:refresh!).and_return(response) + described_class.new({}).refresh! end end