summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-12-30 11:30:56 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-12-30 11:46:47 +0200
commit2660e83c97c46b7303a71b1110c693fbfbc9662c (patch)
tree27a39e3ef6cf679a215fb296ddeb952b22d714b7
parentda9d8279046c7f5f1dfb0972c0c8ac676cfc8b2c (diff)
downloadgitlab-ce-2660e83c97c46b7303a71b1110c693fbfbc9662c.tar.gz
Add group filtering by name for API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--doc/api/groups.md2
-rw-r--r--lib/api/groups.rb13
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