Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get privileges granted on a repo #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/bitbucket_rest_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def lookup_constant(const_name)
:User => 'user',
:Users => 'users',
:Invitations => 'invitations',
:Teams => 'teams'
:Teams => 'teams',
:Privileges => 'privileges'

#:Teams => 'teams',
#:PullRequests => 'pull_requests',
Expand Down
4 changes: 4 additions & 0 deletions lib/bitbucket_rest_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ def user_api(options = {})
def invitations(options = {})
@invitations ||= ApiFactory.new "Invitations", options
end

def privileges(options = {})
@privileges ||= ApiFactory.new 'Privileges', options
end
end # Client
end # BitBucket
22 changes: 22 additions & 0 deletions lib/bitbucket_rest_api/privileges.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# encoding: utf-8

module BitBucket
class Privileges < API
extend AutoloadHelper

def initialize(options = { })
super(options)
end

def repo_list(user_name, repo_name, privilege_account = nil)
_update_user_repo_params(user_name, repo_name)
_validate_user_repo_params(user, repo) unless user? && repo?

if privilege_account
get_request("/1.0/privileges/#{user_name}/#{repo_name}/#{privilege_account}")
else
get_request("/1.0/privileges/#{user_name}/#{repo_name}")
end
end
end
end
37 changes: 37 additions & 0 deletions spec/bitbucket_rest_api/privileges_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'spec_helper'

describe BitBucket::Privileges do
let(:repo) { BitBucket::Privileges.new }

describe '.repo_list' do
context 'without privilege_account' do
before do
expect(repo).to receive(:request).with(
:get,
'/1.0/privileges/mock_username/mock_repo',
{},
{}
)
end

it 'should send a GET request for the given repo' do
repo.repo_list('mock_username', 'mock_repo')
end
end

context 'with privilege_account' do
before do
expect(repo).to receive(:request).with(
:get,
'/1.0/privileges/mock_username/mock_repo/mock_privilege_account',
{},
{}
)
end

it 'should send a GET request for the given repo' do
repo.repo_list('mock_username', 'mock_repo', 'mock_privilege_account')
end
end
end
end