From 314c4746bc24a31efe88b142cd83ab36c3473cc9 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Mon, 12 Dec 2016 16:16:51 +0200 Subject: Specs for Bitbucket::Connections and Bitbucket::Collections --- lib/bitbucket/connection.rb | 20 ++++++++------------ lib/bitbucket/paginator.rb | 4 +--- 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'lib/bitbucket') diff --git a/lib/bitbucket/connection.rb b/lib/bitbucket/connection.rb index 692a596c057..c150a20761e 100644 --- a/lib/bitbucket/connection.rb +++ b/lib/bitbucket/connection.rb @@ -15,18 +15,6 @@ module Bitbucket @refresh_token = options[:refresh_token] end - def client - @client ||= OAuth2::Client.new(provider.app_id, provider.app_secret, options) - end - - def connection - @connection ||= OAuth2::AccessToken.new(client, @token, refresh_token: @refresh_token, expires_at: @expires_at, expires_in: @expires_in) - end - - def set_default_query_parameters(params = {}) - @default_query.merge!(params) - end - def get(path, extra_query = {}) refresh! if expired? @@ -52,6 +40,14 @@ module Bitbucket attr_reader :expires_at, :expires_in, :refresh_token, :token + def client + @client ||= OAuth2::Client.new(provider.app_id, provider.app_secret, options) + end + + def connection + @connection ||= OAuth2::AccessToken.new(client, @token, refresh_token: @refresh_token, expires_at: @expires_at, expires_in: @expires_in) + end + def build_url(path) return path if path.starts_with?(root_url) diff --git a/lib/bitbucket/paginator.rb b/lib/bitbucket/paginator.rb index 641a6ed79d6..b38cd99855c 100644 --- a/lib/bitbucket/paginator.rb +++ b/lib/bitbucket/paginator.rb @@ -7,8 +7,6 @@ module Bitbucket @type = type @url = url @page = nil - - connection.set_default_query_parameters(pagelen: PAGE_LENGTH, sort: :created_on) end def items @@ -31,7 +29,7 @@ module Bitbucket end def fetch_next_page - parsed_response = connection.get(next_url) + parsed_response = connection.get(next_url, { pagelen: PAGE_LENGTH, sort: :created_on }) Page.new(parsed_response, type) end end -- cgit v1.2.1