Add optional search param for Merge Requests API

This commit is contained in:
Mark Fletcher 2017-12-19 22:00:17 +00:00
parent c9732b3c6d
commit 055543b915
4 changed files with 28 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
title: Add optional search param for Merge Requests API
merge_request:
author:
type: fixed

View file

@ -47,6 +47,7 @@ Parameters:
| `author_id` | integer | no | Returns merge requests created by the given user `id`. Combine with `scope=all` or `scope=assigned-to-me` |
| `assignee_id` | integer | no | Returns merge requests assigned to the given user `id` |
| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji` _([Introduced][ce-14016] in GitLab 10.0)_ |
| `search` | string | no | Search merge requests against their `title` and `description` |
```json
[
@ -161,6 +162,7 @@ Parameters:
| `author_id` | integer | no | Returns merge requests created by the given user `id` _([Introduced][ce-13060] in GitLab 9.5)_ |
| `assignee_id` | integer | no | Returns merge requests assigned to the given user `id` _([Introduced][ce-13060] in GitLab 9.5)_ |
| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji` _([Introduced][ce-14016] in GitLab 10.0)_ |
| `search` | string | no | Search merge requests against their `title` and `description` |
```json
[

View file

@ -41,6 +41,7 @@ module API
optional :scope, type: String, values: %w[created-by-me assigned-to-me all],
desc: 'Return merge requests for the given scope: `created-by-me`, `assigned-to-me` or `all`'
optional :my_reaction_emoji, type: String, desc: 'Return issues reacted by the authenticated user by the given emoji'
optional :search, type: String, desc: 'Search merge requests for text present in the title or description'
use :pagination
end
end

View file

@ -150,6 +150,26 @@ describe API::MergeRequests do
expect(json_response.length).to eq(1)
expect(json_response.first['id']).to eq(merge_request3.id)
end
context 'search params' do
before do
merge_request.update(title: 'Search title', description: 'Search description')
end
it 'returns merge requests matching given search string for title' do
get api("/merge_requests", user), search: merge_request.title
expect(json_response.length).to eq(1)
expect(json_response.first['id']).to eq(merge_request.id)
end
it 'returns merge requests for project matching given search string for description' do
get api("/merge_requests", user), project_id: project.id, search: merge_request.description
expect(json_response.length).to eq(1)
expect(json_response.first['id']).to eq(merge_request.id)
end
end
end
end