diff options
-rw-r--r-- | doc/api/groups.md | 2 | ||||
-rw-r--r-- | lib/api/groups.rb | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/doc/api/groups.md b/doc/api/groups.md index 6b379b02d28..8aae4f6b1bb 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -19,6 +19,8 @@ GET /groups ] ``` +You can search for groups by name or path with: `/groups?search=Rails` + ## Details of a group Get all details of a group. diff --git a/lib/api/groups.rb b/lib/api/groups.rb index f0ab6938b1c..a2d915a7eca 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -25,11 +25,14 @@ module API # Example Request: # GET /groups get do - if current_user.admin - @groups = paginate Group - else - @groups = paginate current_user.groups - end + @groups = if current_user.admin + Group.all + else + current_user.groups + end + + @groups = @groups.search(params[:search]) if params[:search].present? + @groups = paginate @groups present @groups, with: Entities::Group end |