Skip to content

Commit

Permalink
Add method to list all members including inherited members (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMGagiu authored Nov 28, 2020
1 parent 8b8a34d commit c6cf6d5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/gitlab/client/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ def team_members(project, options = {})
get("/projects/#{url_encode project}/members", query: options)
end

# Gets a list of all project team members including inherited members.
#
# @example
# Gitlab.all_members(42)
# Gitlab.all_members('gitlab')
#
# @param [Integer, String] project The ID or path of a project.
# @param [Hash] options A customizable set of options.
# @option options [String] :query The search query.
# @option options [Integer] :page The page number.
# @option options [Integer] :per_page The number of results per page.
# @return [Array<Gitlab::ObjectifiedHash>]
def all_members(project, options = {})
get("/projects/#{url_encode project}/members/all", query: options)
end

# Gets a project team member.
#
# @example
Expand Down
16 changes: 16 additions & 0 deletions spec/gitlab/client/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@
end
end

describe '.all_members' do
before do
stub_get('/projects/3/members/all', 'team_members')
@all_members = Gitlab.all_members(3)
end

it 'gets the correct resource' do
expect(a_get('/projects/3/members/all')).to have_been_made
end

it 'returns a paginated response of all team members including inherited' do
expect(@all_members).to be_a Gitlab::PaginatedResponse
expect(@all_members.first.name).to eq('John Smith')
end
end

describe '.team_member' do
before do
stub_get('/projects/3/members/1', 'team_member')
Expand Down

0 comments on commit c6cf6d5

Please sign in to comment.