Merge branch '28257-issues-iids' into 'master'
API issues - support filtering by iids Closes #28257 See merge request !9541
This commit is contained in:
		
						commit
						d77bf0ed71
					
				|  | @ -0,0 +1,4 @@ | ||||||
|  | --- | ||||||
|  | title: API issues - support filtering by iids | ||||||
|  | merge_request: | ||||||
|  | author: | ||||||
|  | @ -25,6 +25,7 @@ GET /issues?labels=foo,bar | ||||||
| GET /issues?labels=foo,bar&state=opened | GET /issues?labels=foo,bar&state=opened | ||||||
| GET /issues?milestone=1.0.0 | GET /issues?milestone=1.0.0 | ||||||
| GET /issues?milestone=1.0.0&state=opened | GET /issues?milestone=1.0.0&state=opened | ||||||
|  | GET /issues?iids[]=42&iids[]=43 | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| | Attribute | Type | Required | Description | | | Attribute | Type | Required | Description | | ||||||
|  | @ -32,6 +33,7 @@ GET /issues?milestone=1.0.0&state=opened | ||||||
| | `state`   | string  | no    | Return all issues or just those that are `opened` or `closed`| | | `state`   | string  | no    | Return all issues or just those that are `opened` or `closed`| | ||||||
| | `labels`  | string  | no    | Comma-separated list of label names, issues must have all labels to be returned | | | `labels`  | string  | no    | Comma-separated list of label names, issues must have all labels to be returned | | ||||||
| | `milestone` | string| no    | The milestone title | | | `milestone` | string| no    | The milestone title | | ||||||
|  | | `iids`    | Array[integer] | no | Return only the issues having the given `iid` | | ||||||
| | `order_by`| string  | no    | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` | | | `order_by`| string  | no    | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` | | ||||||
| | `sort`    | string  | no    | Return requests sorted in `asc` or `desc` order. Default is `desc`  | | | `sort`    | string  | no    | Return requests sorted in `asc` or `desc` order. Default is `desc`  | | ||||||
| 
 | 
 | ||||||
|  | @ -102,6 +104,7 @@ GET /groups/:id/issues?labels=foo,bar | ||||||
| GET /groups/:id/issues?labels=foo,bar&state=opened | GET /groups/:id/issues?labels=foo,bar&state=opened | ||||||
| GET /groups/:id/issues?milestone=1.0.0 | GET /groups/:id/issues?milestone=1.0.0 | ||||||
| GET /groups/:id/issues?milestone=1.0.0&state=opened | GET /groups/:id/issues?milestone=1.0.0&state=opened | ||||||
|  | GET /groups/:id/issues?iids[]=42&iids[]=43 | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| | Attribute | Type | Required | Description | | | Attribute | Type | Required | Description | | ||||||
|  | @ -109,6 +112,7 @@ GET /groups/:id/issues?milestone=1.0.0&state=opened | ||||||
| | `id`      | integer | yes   | The ID of a group | | | `id`      | integer | yes   | The ID of a group | | ||||||
| | `state`   | string  | no    | Return all issues or just those that are `opened` or `closed`| | | `state`   | string  | no    | Return all issues or just those that are `opened` or `closed`| | ||||||
| | `labels`  | string  | no    | Comma-separated list of label names, issues must have all labels to be returned | | | `labels`  | string  | no    | Comma-separated list of label names, issues must have all labels to be returned | | ||||||
|  | | `iids`    | Array[integer] | no | Return only the issues having the given `iid` | | ||||||
| | `milestone` | string| no    | The milestone title | | | `milestone` | string| no    | The milestone title | | ||||||
| | `order_by`| string  | no    | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` | | | `order_by`| string  | no    | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` | | ||||||
| | `sort`    | string  | no    | Return requests sorted in `asc` or `desc` order. Default is `desc`  | | | `sort`    | string  | no    | Return requests sorted in `asc` or `desc` order. Default is `desc`  | | ||||||
|  | @ -181,12 +185,13 @@ GET /projects/:id/issues?labels=foo,bar | ||||||
| GET /projects/:id/issues?labels=foo,bar&state=opened | GET /projects/:id/issues?labels=foo,bar&state=opened | ||||||
| GET /projects/:id/issues?milestone=1.0.0 | GET /projects/:id/issues?milestone=1.0.0 | ||||||
| GET /projects/:id/issues?milestone=1.0.0&state=opened | GET /projects/:id/issues?milestone=1.0.0&state=opened | ||||||
|  | GET /projects/:id/issues?iids[]=42&iids[]=43 | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| | Attribute | Type | Required | Description | | | Attribute | Type | Required | Description | | ||||||
| | --------- | ---- | -------- | ----------- | | | --------- | ---- | -------- | ----------- | | ||||||
| | `id`      | integer | yes   | The ID of a project | | | `id`      | integer | yes   | The ID of a project | | ||||||
| | `iid`     | integer | no    | Return the issue having the given `iid` | | | `iids`    | Array[integer] | no | Return only the milestone having the given `iid` | | ||||||
| | `state`   | string  | no    | Return all issues or just those that are `opened` or `closed`| | | `state`   | string  | no    | Return all issues or just those that are `opened` or `closed`| | ||||||
| | `labels`  | string  | no    | Comma-separated list of label names, issues must have all labels to be returned | | | `labels`  | string  | no    | Comma-separated list of label names, issues must have all labels to be returned | | ||||||
| | `milestone` | string| no    | The milestone title | | | `milestone` | string| no    | The milestone title | | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ module API | ||||||
|         optional :sort, type: String, values: %w[asc desc], default: 'desc', |         optional :sort, type: String, values: %w[asc desc], default: 'desc', | ||||||
|                         desc: 'Return issues sorted in `asc` or `desc` order.' |                         desc: 'Return issues sorted in `asc` or `desc` order.' | ||||||
|         optional :milestone, type: String, desc: 'Return issues for a specific milestone' |         optional :milestone, type: String, desc: 'Return issues for a specific milestone' | ||||||
|  |         optional :iids, type: Array[Integer], desc: 'The IID array of issues' | ||||||
|         use :pagination |         use :pagination | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -212,6 +212,25 @@ describe API::Issues, api: true  do | ||||||
|         expect(json_response.first['id']).to eq(confidential_issue.id) |         expect(json_response.first['id']).to eq(confidential_issue.id) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|  |       it 'returns an array of issues found by iids' do | ||||||
|  |         get api('/issues', user), iids: [closed_issue.iid] | ||||||
|  | 
 | ||||||
|  |         expect(response).to have_http_status(200) | ||||||
|  |         expect(response).to include_pagination_headers | ||||||
|  |         expect(json_response).to be_an Array | ||||||
|  |         expect(json_response.length).to eq(1) | ||||||
|  |         expect(json_response.first['id']).to eq(closed_issue.id) | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|  |       it 'returns an empty array if iid does not exist' do | ||||||
|  |         get api("/issues", user), iids: [99999] | ||||||
|  | 
 | ||||||
|  |         expect(response).to have_http_status(200) | ||||||
|  |         expect(response).to include_pagination_headers | ||||||
|  |         expect(json_response).to be_an Array | ||||||
|  |         expect(json_response.length).to eq(0) | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|       it 'sorts by created_at descending by default' do |       it 'sorts by created_at descending by default' do | ||||||
|         get api('/issues', user) |         get api('/issues', user) | ||||||
| 
 | 
 | ||||||
|  | @ -377,6 +396,25 @@ describe API::Issues, api: true  do | ||||||
|       expect(json_response.first['labels']).to eq([label_c.title, label_b.title, group_label.title]) |       expect(json_response.first['labels']).to eq([label_c.title, label_b.title, group_label.title]) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |     it 'returns an array of issues found by iids' do | ||||||
|  |       get api(base_url, user), iids: [group_issue.iid] | ||||||
|  | 
 | ||||||
|  |       expect(response).to have_http_status(200) | ||||||
|  |       expect(response).to include_pagination_headers | ||||||
|  |       expect(json_response).to be_an Array | ||||||
|  |       expect(json_response.length).to eq(1) | ||||||
|  |       expect(json_response.first['id']).to eq(group_issue.id) | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|  |     it 'returns an empty array if iid does not exist' do | ||||||
|  |       get api(base_url, user), iids: [99999] | ||||||
|  | 
 | ||||||
|  |       expect(response).to have_http_status(200) | ||||||
|  |       expect(response).to include_pagination_headers | ||||||
|  |       expect(json_response).to be_an Array | ||||||
|  |       expect(json_response.length).to eq(0) | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|     it 'returns an empty array if no group issue matches labels' do |     it 'returns an empty array if no group issue matches labels' do | ||||||
|       get api("#{base_url}?labels=foo,bar", user) |       get api("#{base_url}?labels=foo,bar", user) | ||||||
| 
 | 
 | ||||||
|  | @ -586,6 +624,25 @@ describe API::Issues, api: true  do | ||||||
|       expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title]) |       expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title]) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |     it 'returns an array of issues found by iids' do | ||||||
|  |       get api("#{base_url}/issues", user), iids: [issue.iid] | ||||||
|  | 
 | ||||||
|  |       expect(response).to have_http_status(200) | ||||||
|  |       expect(response).to include_pagination_headers | ||||||
|  |       expect(json_response).to be_an Array | ||||||
|  |       expect(json_response.length).to eq(1) | ||||||
|  |       expect(json_response.first['id']).to eq(issue.id) | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|  |     it 'returns an empty array if iid does not exist' do | ||||||
|  |       get api("#{base_url}/issues", user), iids: [99999] | ||||||
|  | 
 | ||||||
|  |       expect(response).to have_http_status(200) | ||||||
|  |       expect(response).to include_pagination_headers | ||||||
|  |       expect(json_response).to be_an Array | ||||||
|  |       expect(json_response.length).to eq(0) | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|     it 'returns an empty array if not all labels matches' do |     it 'returns an empty array if not all labels matches' do | ||||||
|       get api("#{base_url}/issues?labels=#{label.title},foo", user) |       get api("#{base_url}/issues?labels=#{label.title},foo", user) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue