Skip to content

Commit ef0d50c

Browse files
committed
Support optional parameters to .group
The Group details API has support for two optional flags, which include custom attributes in the response, and allows limiting the details returned. See https://docs.gitlab.com/ee/api/groups.html#details-of-a-group
1 parent 216251a commit ef0d50c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/gitlab/client/groups.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ def groups(options = {})
2424
# Gitlab.group(42)
2525
#
2626
# @param [Integer] id The ID of a group.
27+
# @param [Hash] options A customizable set of options.
28+
# @option options [Boolean] :with_custom_attributes Include custom attributes in response (admins only)
29+
# @option options [Boolean] :with_projects Include details about group projects (default: true)
2730
# @return [Gitlab::ObjectifiedHash]
28-
def group(id)
29-
get("/groups/#{url_encode id}")
31+
def group(id, options = {})
32+
get("/groups/#{url_encode id}", query: options)
3033
end
3134

3235
# Creates a new group.

spec/gitlab/client/groups_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
end
2323
end
2424

25+
describe '.group' do
26+
before do
27+
stub_get('/groups/3?with_projects=false', 'group')
28+
@group = Gitlab.group(3, with_projects: false)
29+
end
30+
31+
it 'gets the correct resource' do
32+
expect(a_get('/groups/3?with_projects=false')).to have_been_made
33+
end
34+
end
35+
2536
describe '.create_group' do
2637
context 'without description' do
2738
before do

0 commit comments

Comments
 (0)