Skip to content

Commit

Permalink
Merge pull request #637 from garaujodev/add-group-descendants-endpoint
Browse files Browse the repository at this point in the history
Add group descendants endpoint
  • Loading branch information
NARKOZ committed Apr 8, 2022
2 parents 64818aa + 0438984 commit fcab58c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/gitlab/client/groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ def group_members(id, options = {})
get("/groups/#{url_encode id}/members", query: options)
end

# Get a list of descendant groups of a group.
#
# @example
# Gitlab.group_descendants(42)
#
# @param [Integer] id the ID of a group
# @param [Hash] options A customizable set of options.
# @option options [String] :skip_groups Skip the group IDs passed.
# @option options [String] :all_available Show all the groups you have access to (defaults to false for authenticated users).
# @option options [String] :search Return the list of authorized groups matching the search criteria.
# @option options [String] :order_by Order groups by name or path. Default is name.
# @option options [String] :sort Order groups in asc or desc order. Default is asc.
# @option options [String] :statistics Include group statistics (admins only).
# @option options [String] :owned Limit to groups owned by the current user.
# @return [Array<Gitlab::ObjectifiedHash>] List of all subgroups under a group
def group_descendants(id, options = {})
get("/groups/#{url_encode id}/descendant_groups", query: options)
end

# Get a list of group members that are billable.
#
# @example
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/group_descendants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id": 1,"name":"Foobar Group","path":"foo-bar","description":"An interesting group","visibility":"public","lfs_enabled":true,"avatar_url":"http://gitlab.example.com/uploads/group/avatar/1/foo.jpg","web_url":"http://gitlab.example.com/groups/foo-bar","request_access_enabled":false,"full_name":"Foobar Group","full_path":"foo-bar","parent_id":3},{"id":2,"name": "Foobar Group 2","path":"foo-bar-2","description":"Another interesting group","visibility":"public","lfs_enabled":true,"avatar_url":"http://gitlab.example.com/uploads/group/avatar/2/foo.jpg","web_url":"http://gitlab.example.com/groups/foo-bar-2","request_access_enabled":false,"full_name":"Foobar Group 2","full_path":"foo-bar-2","parent_id":1}]
17 changes: 17 additions & 0 deletions spec/gitlab/client/groups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@
end
end

describe '.group_descendants' do
before do
stub_get('/groups/3/descendant_groups', 'group_descendants')
@descendants = Gitlab.group_descendants(3)
end

it 'gets the correct resource' do
expect(a_get('/groups/3/descendant_groups')).to have_been_made
end

it "returns information about a group's descendants" do
expect(@descendants).to be_a Gitlab::PaginatedResponse
expect(@descendants.size).to eq(2)
expect(@descendants[1].name).to eq('Foobar Group 2')
end
end

describe '.group_billable_members' do
before do
stub_get('/groups/3/billable_members', 'group_billable_members')
Expand Down

0 comments on commit fcab58c

Please sign in to comment.