Commit 6ea8fc2f authored by Jan Provaznik's avatar Jan Provaznik

Optional '/-/' delimiter for epics and search API

'/-/' delimiter is used only in UI, in API we don't use it for
other endpoints. To align epics and search endpoints with the rest of API
endpoints, this patch makes '/-/' optional for existing endpoints (to
keep backward compatibility), for new endpoints (epic notes, discussions)
'/-/' path is not included.

Documentation is updated to prefer paths without '/-/'.

Closes #5245
parent 81503c33
...@@ -10,7 +10,7 @@ Epics are available only in Ultimate. If epics feature is not available a `403` ...@@ -10,7 +10,7 @@ Epics are available only in Ultimate. If epics feature is not available a `403`
Gets all issues that are assigned to an epic and the authenticated user has access to. Gets all issues that are assigned to an epic and the authenticated user has access to.
``` ```
GET /groups/:id/-/epics/:epic_iid/issues GET /groups/:id/epics/:epic_iid/issues
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -19,7 +19,7 @@ GET /groups/:id/-/epics/:epic_iid/issues ...@@ -19,7 +19,7 @@ GET /groups/:id/-/epics/:epic_iid/issues
| `epic_iid` | integer/string | yes | The internal ID of the epic. | | `epic_iid` | integer/string | yes | The internal ID of the epic. |
```bash ```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics/5/issues/ curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics/5/issues/
``` ```
Example response: Example response:
...@@ -106,7 +106,7 @@ Example response: ...@@ -106,7 +106,7 @@ Example response:
Creates an epic - issue association. If the issue in question belongs to another epic it is unassigned from that epic. Creates an epic - issue association. If the issue in question belongs to another epic it is unassigned from that epic.
``` ```
POST /groups/:id/-/epics/:epic_iid/issues/:issue_id POST /groups/:id/epics/:epic_iid/issues/:issue_id
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -116,7 +116,7 @@ POST /groups/:id/-/epics/:epic_iid/issues/:issue_id ...@@ -116,7 +116,7 @@ POST /groups/:id/-/epics/:epic_iid/issues/:issue_id
| `issue_id` | integer/string | yes | The ID of the issue. | | `issue_id` | integer/string | yes | The ID of the issue. |
```bash ```bash
curl --header POST "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics/5/issues/55 curl --header POST "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics/5/issues/55
``` ```
Example response: Example response:
...@@ -212,7 +212,7 @@ Example response: ...@@ -212,7 +212,7 @@ Example response:
Removes an epic - issue association. Removes an epic - issue association.
``` ```
DELETE /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id DELETE /groups/:id/epics/:epic_iid/issues/:epic_issue_id
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -222,7 +222,7 @@ DELETE /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id ...@@ -222,7 +222,7 @@ DELETE /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id
| `epic_issue_id` | integer/string | yes | The ID of the issue - epic association. | | `epic_issue_id` | integer/string | yes | The ID of the issue - epic association. |
```bash ```bash
curl --header DELETE "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics/5/issues/11 curl --header DELETE "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics/5/issues/11
``` ```
Example response: Example response:
...@@ -318,7 +318,7 @@ Example response: ...@@ -318,7 +318,7 @@ Example response:
Updates an epic - issue association. Updates an epic - issue association.
``` ```
PUT /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id PUT /groups/:id/epics/:epic_iid/issues/:epic_issue_id
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -330,7 +330,7 @@ PUT /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id ...@@ -330,7 +330,7 @@ PUT /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id
| `move_after_id` | integer/string | no | The ID of the issue - epic association that should be placed after the link in the question. | | `move_after_id` | integer/string | no | The ID of the issue - epic association that should be placed after the link in the question. |
```bash ```bash
curl --header PUT "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics/5/issues/11?move_before_id=20 curl --header PUT "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics/5/issues/11?move_before_id=20
``` ```
Example response: Example response:
......
...@@ -15,9 +15,9 @@ The [epic issues API](epic_issues.md) allows you to interact with issues associa ...@@ -15,9 +15,9 @@ The [epic issues API](epic_issues.md) allows you to interact with issues associa
Gets all epics of the requested group and its subgroups. Gets all epics of the requested group and its subgroups.
``` ```
GET /groups/:id/-/epics GET /groups/:id/epics
GET /groups/:id/-/epics?author_id=5 GET /groups/:id/epics?author_id=5
GET /groups/:id/-/epics?labels=bug,reproduced GET /groups/:id/epics?labels=bug,reproduced
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -30,7 +30,7 @@ GET /groups/:id/-/epics?labels=bug,reproduced ...@@ -30,7 +30,7 @@ GET /groups/:id/-/epics?labels=bug,reproduced
| `search` | string | no | Search epics against their `title` and `description` | | `search` | string | no | Search epics against their `title` and `description` |
```bash ```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics
``` ```
Example response: Example response:
...@@ -65,7 +65,7 @@ Example response: ...@@ -65,7 +65,7 @@ Example response:
Gets a single epic Gets a single epic
``` ```
GET /groups/:id/-/epics/:epic_iid GET /groups/:id/epics/:epic_iid
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -74,7 +74,7 @@ GET /groups/:id/-/epics/:epic_iid ...@@ -74,7 +74,7 @@ GET /groups/:id/-/epics/:epic_iid
| `epic_iid` | integer/string | yes | The internal ID of the epic. | | `epic_iid` | integer/string | yes | The internal ID of the epic. |
```bash ```bash
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics/5 curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics/5
``` ```
Example response: Example response:
...@@ -106,7 +106,7 @@ Example response: ...@@ -106,7 +106,7 @@ Example response:
Creates a new epic Creates a new epic
``` ```
POST /groups/:id/-/epics POST /groups/:id/epics
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -119,7 +119,7 @@ POST /groups/:id/-/epics ...@@ -119,7 +119,7 @@ POST /groups/:id/-/epics
| `end_date` | string. | no | The end date of the epic | | `end_date` | string. | no | The end date of the epic |
```bash ```bash
curl --header POST "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics?title=Epic&description=Epic%20description curl --header POST "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics?title=Epic&description=Epic%20description
``` ```
Example response: Example response:
...@@ -152,7 +152,7 @@ Example response: ...@@ -152,7 +152,7 @@ Example response:
Updates an epic Updates an epic
``` ```
PUT /groups/:id/-/epics/:epic_iid PUT /groups/:id/epics/:epic_iid
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -166,7 +166,7 @@ PUT /groups/:id/-/epics/:epic_iid ...@@ -166,7 +166,7 @@ PUT /groups/:id/-/epics/:epic_iid
| `end_date` | string. | no | The end date of an epic | | `end_date` | string. | no | The end date of an epic |
```bash ```bash
curl --header PUT "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics/5?title=New%20Title curl --header PUT "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics/5?title=New%20Title
``` ```
Example response: Example response:
...@@ -199,7 +199,7 @@ Example response: ...@@ -199,7 +199,7 @@ Example response:
Deletes an epic Deletes an epic
``` ```
DELETE /groups/:id/-/epics/:epic_iid DELETE /groups/:id/epics/:epic_iid
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -208,5 +208,5 @@ DELETE /groups/:id/-/epics/:epic_iid ...@@ -208,5 +208,5 @@ DELETE /groups/:id/-/epics/:epic_iid
| `epic_iid` | integer/string | yes | The internal ID of the epic. | | `epic_iid` | integer/string | yes | The internal ID of the epic. |
```bash ```bash
curl --header DELETE "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/-/epics/5?title=New%20Title curl --header DELETE "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/1/epics/5?title=New%20Title
``` ```
...@@ -374,7 +374,7 @@ Search within the specified group. ...@@ -374,7 +374,7 @@ Search within the specified group.
If a user is not a member of a group and the group is private, a `GET` request on that group will result to a `404` status code. If a user is not a member of a group and the group is private, a `GET` request on that group will result to a `404` status code.
``` ```
GET /groups/:id/-/search GET /groups/:id/search
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -392,7 +392,7 @@ The response depends on the requested scope. ...@@ -392,7 +392,7 @@ The response depends on the requested scope.
### Scope: projects ### Scope: projects
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/3/-/search?scope=projects&search=flight curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/3/search?scope=projects&search=flight
``` ```
Example response: Example response:
...@@ -423,7 +423,7 @@ Example response: ...@@ -423,7 +423,7 @@ Example response:
### Scope: issues ### Scope: issues
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/3/-/search?scope=issues&search=file curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/3/search?scope=issues&search=file
``` ```
Example response: Example response:
...@@ -488,7 +488,7 @@ Example response: ...@@ -488,7 +488,7 @@ Example response:
### Scope: merge_requests ### Scope: merge_requests
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/3/-/search?scope=merge_requests&search=file curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/3/search?scope=merge_requests&search=file
``` ```
Example response: Example response:
...@@ -565,7 +565,7 @@ Example response: ...@@ -565,7 +565,7 @@ Example response:
### Scope: milestones ### Scope: milestones
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/3/-/search?scope=milestones&search=release curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/3/search?scope=milestones&search=release
``` ```
Example response: Example response:
...@@ -592,7 +592,7 @@ Example response: ...@@ -592,7 +592,7 @@ Example response:
This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled. This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled.
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/6/-/search?scope=wiki_blobs&search=bye curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/6/search?scope=wiki_blobs&search=bye
``` ```
Example response: Example response:
...@@ -617,7 +617,7 @@ Example response: ...@@ -617,7 +617,7 @@ Example response:
This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled. This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled.
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/6/-/search?scope=commits&search=bye curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/6/search?scope=commits&search=bye
``` ```
Example response: Example response:
...@@ -650,7 +650,7 @@ Example response: ...@@ -650,7 +650,7 @@ Example response:
This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled. This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled.
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/6/-/search?scope=blobs&search=installation curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/6/search?scope=blobs&search=installation
``` ```
Example response: Example response:
...@@ -677,7 +677,7 @@ Search within the specified project. ...@@ -677,7 +677,7 @@ Search within the specified project.
If a user is not a member of a project and the project is private, a `GET` request on that project will result to a `404` status code. If a user is not a member of a project and the project is private, a `GET` request on that project will result to a `404` status code.
``` ```
GET /projects/:id/-/search GET /projects/:id/search
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -694,7 +694,7 @@ The response depends on the requested scope. ...@@ -694,7 +694,7 @@ The response depends on the requested scope.
### Scope: issues ### Scope: issues
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/12/-/search?scope=issues&search=file curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/12/search?scope=issues&search=file
``` ```
Example response: Example response:
...@@ -759,7 +759,7 @@ Example response: ...@@ -759,7 +759,7 @@ Example response:
### Scope: merge_requests ### Scope: merge_requests
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/-/search?scope=merge_requests&search=file curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/search?scope=merge_requests&search=file
``` ```
Example response: Example response:
...@@ -836,7 +836,7 @@ Example response: ...@@ -836,7 +836,7 @@ Example response:
### Scope: milestones ### Scope: milestones
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/12/-/search?scope=milestones&search=release curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/12/search?scope=milestones&search=release
``` ```
Example response: Example response:
...@@ -861,7 +861,7 @@ Example response: ...@@ -861,7 +861,7 @@ Example response:
### Scope: notes ### Scope: notes
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/-/search?scope=notes&search=maxime curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/search?scope=notes&search=maxime
``` ```
Example response: Example response:
...@@ -893,7 +893,7 @@ Example response: ...@@ -893,7 +893,7 @@ Example response:
### Scope: wiki_blobs ### Scope: wiki_blobs
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/-/search?scope=wiki_blobs&search=bye curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/search?scope=wiki_blobs&search=bye
``` ```
Example response: Example response:
...@@ -916,7 +916,7 @@ Example response: ...@@ -916,7 +916,7 @@ Example response:
### Scope: commits ### Scope: commits
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/-/search?scope=commits&search=bye curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/search?scope=commits&search=bye
``` ```
Example response: Example response:
...@@ -947,7 +947,7 @@ Example response: ...@@ -947,7 +947,7 @@ Example response:
### Scope: blobs ### Scope: blobs
```bash ```bash
curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/-/search?scope=blobs&search=installation curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/search?scope=blobs&search=installation
``` ```
Example response: Example response:
......
---
title: Make /-/ delimiter optional for epics and search endpoints
merge_request:
author:
type: changed
...@@ -40,7 +40,7 @@ module API ...@@ -40,7 +40,7 @@ module API
optional :move_before_id, type: Integer, desc: 'The id of the epic issue association that should be positioned before the actual issue' optional :move_before_id, type: Integer, desc: 'The id of the epic issue association that should be positioned before the actual issue'
optional :move_after_id, type: Integer, desc: 'The id of the epic issue association that should be positioned after the actual issue' optional :move_after_id, type: Integer, desc: 'The id of the epic issue association that should be positioned after the actual issue'
end end
put ':id/-/epics/:epic_iid/issues/:epic_issue_id' do put ':id/(-/)epics/:epic_iid/issues/:epic_issue_id' do
authorize_can_admin! authorize_can_admin!
update_params = { update_params = {
...@@ -67,7 +67,7 @@ module API ...@@ -67,7 +67,7 @@ module API
params do params do
requires :epic_iid, type: Integer, desc: 'The iid of the epic' requires :epic_iid, type: Integer, desc: 'The iid of the epic'
end end
get ':id/-/epics/:epic_iid/issues' do get ':id/(-/)epics/:epic_iid/issues' do
authorize_can_read! authorize_can_read!
present epic.issues(current_user), present epic.issues(current_user),
...@@ -81,7 +81,7 @@ module API ...@@ -81,7 +81,7 @@ module API
params do params do
requires :epic_iid, type: Integer, desc: 'The iid of the epic' requires :epic_iid, type: Integer, desc: 'The iid of the epic'
end end
post ':id/-/epics/:epic_iid/issues/:issue_id' do post ':id/(-/)epics/:epic_iid/issues/:issue_id' do
authorize_can_admin! authorize_can_admin!
issue = Issue.find(params[:issue_id]) issue = Issue.find(params[:issue_id])
...@@ -106,7 +106,7 @@ module API ...@@ -106,7 +106,7 @@ module API
requires :epic_iid, type: Integer, desc: 'The iid of the epic' requires :epic_iid, type: Integer, desc: 'The iid of the epic'
requires :epic_issue_id, type: Integer, desc: 'The id of the association' requires :epic_issue_id, type: Integer, desc: 'The id of the association'
end end
delete ':id/-/epics/:epic_iid/issues/:epic_issue_id' do delete ':id/(-/)epics/:epic_iid/issues/:epic_issue_id' do
authorize_can_admin! authorize_can_admin!
result = ::EpicIssues::DestroyService.new(link, current_user).execute result = ::EpicIssues::DestroyService.new(link, current_user).execute
......
...@@ -57,7 +57,7 @@ module API ...@@ -57,7 +57,7 @@ module API
optional :author_id, type: Integer, desc: 'Return epics which are authored by the user with the given ID' optional :author_id, type: Integer, desc: 'Return epics which are authored by the user with the given ID'
optional :labels, type: String, desc: 'Comma-separated list of label names' optional :labels, type: String, desc: 'Comma-separated list of label names'
end end
get ':id/-/epics' do get ':id/(-/)epics' do
present find_epics(group_id: user_group.id), with: EE::API::Entities::Epic present find_epics(group_id: user_group.id), with: EE::API::Entities::Epic
end end
...@@ -67,7 +67,7 @@ module API ...@@ -67,7 +67,7 @@ module API
params do params do
requires :epic_iid, type: Integer, desc: 'The internal ID of an epic' requires :epic_iid, type: Integer, desc: 'The internal ID of an epic'
end end
get ':id/-/epics/:epic_iid' do get ':id/(-/)epics/:epic_iid' do
authorize_can_read! authorize_can_read!
present epic, with: EE::API::Entities::Epic present epic, with: EE::API::Entities::Epic
...@@ -83,7 +83,7 @@ module API ...@@ -83,7 +83,7 @@ module API
optional :end_date, type: String, desc: 'The end date of an epic' optional :end_date, type: String, desc: 'The end date of an epic'
optional :labels, type: String, desc: 'Comma-separated list of label names' optional :labels, type: String, desc: 'Comma-separated list of label names'
end end
post ':id/-/epics' do post ':id/(-/)epics' do
authorize_can_create! authorize_can_create!
epic = ::Epics::CreateService.new(user_group, current_user, declared_params(include_missing: false)).execute epic = ::Epics::CreateService.new(user_group, current_user, declared_params(include_missing: false)).execute
...@@ -106,7 +106,7 @@ module API ...@@ -106,7 +106,7 @@ module API
optional :labels, type: String, desc: 'Comma-separated list of label names' optional :labels, type: String, desc: 'Comma-separated list of label names'
at_least_one_of :title, :description, :start_date, :end_date, :labels at_least_one_of :title, :description, :start_date, :end_date, :labels
end end
put ':id/-/epics/:epic_iid' do put ':id/(-/)epics/:epic_iid' do
authorize_can_admin! authorize_can_admin!
update_params = declared_params(include_missing: false) update_params = declared_params(include_missing: false)
update_params.delete(:epic_iid) update_params.delete(:epic_iid)
...@@ -126,7 +126,7 @@ module API ...@@ -126,7 +126,7 @@ module API
params do params do
requires :epic_iid, type: Integer, desc: 'The internal ID of an epic' requires :epic_iid, type: Integer, desc: 'The internal ID of an epic'
end end
delete ':id/-/epics/:epic_iid' do delete ':id/(-/)epics/:epic_iid' do
authorize_can_destroy! authorize_can_destroy!
Issuable::DestroyService.new(nil, current_user).execute(epic) Issuable::DestroyService.new(nil, current_user).execute(epic)
......
...@@ -6,8 +6,8 @@ describe API::EpicIssues do ...@@ -6,8 +6,8 @@ describe API::EpicIssues do
let(:project) { create(:project, :public, group: group) } let(:project) { create(:project, :public, group: group) }
let(:epic) { create(:epic, group: group) } let(:epic) { create(:epic, group: group) }
describe 'GET /groups/:id/-/epics/:epic_iid/issues' do describe 'GET /groups/:id/epics/:epic_iid/issues' do
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}/issues" } let(:url) { "/groups/#{group.path}/epics/#{epic.iid}/issues" }
context 'when epics feature is disabled' do context 'when epics feature is disabled' do
it 'returns 403 forbidden error' do it 'returns 403 forbidden error' do
...@@ -61,9 +61,9 @@ describe API::EpicIssues do ...@@ -61,9 +61,9 @@ describe API::EpicIssues do
end end
end end
describe 'POST /groups/:id/-/epics/:epic_iid/issues' do describe 'POST /groups/:id/epics/:epic_iid/issues' do
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}/issues/#{issue.id}" } let(:url) { "/groups/#{group.path}/epics/#{epic.iid}/issues/#{issue.id}" }
context 'when epics feature is disabled' do context 'when epics feature is disabled' do
it 'returns 403 forbidden error' do it 'returns 403 forbidden error' do
...@@ -145,10 +145,10 @@ describe API::EpicIssues do ...@@ -145,10 +145,10 @@ describe API::EpicIssues do
end end
end end
describe 'DELETE /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id"' do describe 'DELETE /groups/:id/epics/:epic_iid/issues/:epic_issue_id"' do
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let!(:epic_issue) { create(:epic_issue, epic: epic, issue: issue) } let!(:epic_issue) { create(:epic_issue, epic: epic, issue: issue) }
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}/issues/#{epic_issue.id}" } let(:url) { "/groups/#{group.path}/epics/#{epic.iid}/issues/#{epic_issue.id}" }
context 'when epics feature is disabled' do context 'when epics feature is disabled' do
it 'returns 403 forbidden error' do it 'returns 403 forbidden error' do
...@@ -229,12 +229,12 @@ describe API::EpicIssues do ...@@ -229,12 +229,12 @@ describe API::EpicIssues do
end end
end end
describe 'PUT /groups/:id/-/epics/:epic_iid/issues/:epic_issue_id' do describe 'PUT /groups/:id/epics/:epic_iid/issues/:epic_issue_id' do
let(:issues) { create_list(:issue, 2, project: project) } let(:issues) { create_list(:issue, 2, project: project) }
let!(:epic_issue1) { create(:epic_issue, epic: epic, issue: issues[0], relative_position: 1) } let!(:epic_issue1) { create(:epic_issue, epic: epic, issue: issues[0], relative_position: 1) }
let!(:epic_issue2) { create(:epic_issue, epic: epic, issue: issues[1], relative_position: 2) } let!(:epic_issue2) { create(:epic_issue, epic: epic, issue: issues[1], relative_position: 2) }
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}/issues/#{epic_issue1.id}?move_after_id=#{epic_issue2.id}" } let(:url) { "/groups/#{group.path}/epics/#{epic.iid}/issues/#{epic_issue1.id}?move_after_id=#{epic_issue2.id}" }
context 'when epics feature is disabled' do context 'when epics feature is disabled' do
it 'returns 403 forbidden error' do it 'returns 403 forbidden error' do
...@@ -274,7 +274,7 @@ describe API::EpicIssues do ...@@ -274,7 +274,7 @@ describe API::EpicIssues do
it 'returns 404 not found error for the link of another epic' do it 'returns 404 not found error for the link of another epic' do
group.add_developer(user) group.add_developer(user)
another_epic = create(:epic, group: group) another_epic = create(:epic, group: group)
url = "/groups/#{group.path}/-/epics/#{another_epic.iid}/issues/#{epic_issue1.id}?move_after_id=#{epic_issue2.id}" url = "/groups/#{group.path}/epics/#{another_epic.iid}/issues/#{epic_issue1.id}?move_after_id=#{epic_issue2.id}"
put api(url, user) put api(url, user)
......
...@@ -40,8 +40,8 @@ describe API::Epics do ...@@ -40,8 +40,8 @@ describe API::Epics do
end end
end end
describe 'GET /groups/:id/-/epics' do describe 'GET /groups/:id/epics' do
let(:url) { "/groups/#{group.path}/-/epics" } let(:url) { "/groups/#{group.path}/epics" }
it_behaves_like 'error requests' it_behaves_like 'error requests'
...@@ -141,8 +141,8 @@ describe API::Epics do ...@@ -141,8 +141,8 @@ describe API::Epics do
end end
end end
describe 'GET /groups/:id/-/epics/:epic_iid' do describe 'GET /groups/:id/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}" } let(:url) { "/groups/#{group.path}/epics/#{epic.iid}" }
it_behaves_like 'error requests' it_behaves_like 'error requests'
...@@ -163,8 +163,8 @@ describe API::Epics do ...@@ -163,8 +163,8 @@ describe API::Epics do
end end
end end
describe 'POST /groups/:id/-/epics' do describe 'POST /groups/:id/epics' do
let(:url) { "/groups/#{group.path}/-/epics" } let(:url) { "/groups/#{group.path}/epics" }
let(:params) { { title: 'new epic', description: 'epic description', labels: 'label1' } } let(:params) { { title: 'new epic', description: 'epic description', labels: 'label1' } }
it_behaves_like 'error requests' it_behaves_like 'error requests'
...@@ -210,8 +210,8 @@ describe API::Epics do ...@@ -210,8 +210,8 @@ describe API::Epics do
end end
end end
describe 'PUT /groups/:id/-/epics/:epic_iid' do describe 'PUT /groups/:id/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}" } let(:url) { "/groups/#{group.path}/epics/#{epic.iid}" }
let(:params) { { title: 'new title', description: 'new description', labels: 'label2' } } let(:params) { { title: 'new title', description: 'new description', labels: 'label2' } }
it_behaves_like 'error requests' it_behaves_like 'error requests'
...@@ -265,8 +265,8 @@ describe API::Epics do ...@@ -265,8 +265,8 @@ describe API::Epics do
end end
end end
describe 'DELETE /groups/:id/-/epics/:epic_iid' do describe 'DELETE /groups/:id/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}" } let(:url) { "/groups/#{group.path}/epics/#{epic.iid}" }
it_behaves_like 'error requests' it_behaves_like 'error requests'
......
...@@ -107,7 +107,7 @@ module API ...@@ -107,7 +107,7 @@ module API
values: %w(projects issues merge_requests milestones wiki_blobs blobs commits) values: %w(projects issues merge_requests milestones wiki_blobs blobs commits)
use :pagination use :pagination
end end
get ':id/-/search' do get ':id/(-/)search' do
check_elasticsearch_scope! check_elasticsearch_scope!
present search(group_id: user_group.id), with: entity present search(group_id: user_group.id), with: entity
...@@ -128,7 +128,7 @@ module API ...@@ -128,7 +128,7 @@ module API
values: %w(issues merge_requests milestones notes wiki_blobs commits blobs) values: %w(issues merge_requests milestones notes wiki_blobs commits blobs)
use :pagination use :pagination
end end
get ':id/-/search' do get ':id/(-/)search' do
present search(project_id: user_project.id), with: entity present search(project_id: user_project.id), with: entity
end end
end end
......
...@@ -99,10 +99,10 @@ describe API::Search do ...@@ -99,10 +99,10 @@ describe API::Search do
end end
end end
describe "GET /groups/:id/-/search" do describe "GET /groups/:id/search" do
context 'when user is not authenticated' do context 'when user is not authenticated' do
it 'returns 401 error' do it 'returns 401 error' do
get api("/groups/#{group.id}/-/search"), scope: 'projects', search: 'awesome' get api("/groups/#{group.id}/search"), scope: 'projects', search: 'awesome'
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(401)
end end
...@@ -110,7 +110,7 @@ describe API::Search do ...@@ -110,7 +110,7 @@ describe API::Search do
context 'when scope is not supported' do context 'when scope is not supported' do
it 'returns 400 error' do it 'returns 400 error' do
get api("/groups/#{group.id}/-/search", user), scope: 'unsupported', search: 'awesome' get api("/groups/#{group.id}/search", user), scope: 'unsupported', search: 'awesome'
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
...@@ -118,7 +118,7 @@ describe API::Search do ...@@ -118,7 +118,7 @@ describe API::Search do
context 'when scope is missing' do context 'when scope is missing' do
it 'returns 400 error' do it 'returns 400 error' do
get api("/groups/#{group.id}/-/search", user), search: 'awesome' get api("/groups/#{group.id}/search", user), search: 'awesome'
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
...@@ -126,7 +126,7 @@ describe API::Search do ...@@ -126,7 +126,7 @@ describe API::Search do
context 'when group does not exist' do context 'when group does not exist' do
it 'returns 404 error' do it 'returns 404 error' do
get api('/groups/9999/-/search', user), scope: 'issues', search: 'awesome' get api('/groups/9999/search', user), scope: 'issues', search: 'awesome'
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
end end
...@@ -136,7 +136,7 @@ describe API::Search do ...@@ -136,7 +136,7 @@ describe API::Search do
it 'returns 404 error' do it 'returns 404 error' do
private_group = create(:group, :private) private_group = create(:group, :private)
get api("/groups/#{private_group.id}/-/search", user), scope: 'issues', search: 'awesome' get api("/groups/#{private_group.id}/search", user), scope: 'issues', search: 'awesome'
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
end end
...@@ -145,7 +145,7 @@ describe API::Search do ...@@ -145,7 +145,7 @@ describe API::Search do
context 'with correct params' do context 'with correct params' do
context 'for projects scope' do context 'for projects scope' do
before do before do
get api("/groups/#{group.id}/-/search", user), scope: 'projects', search: 'awesome' get api("/groups/#{group.id}/search", user), scope: 'projects', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/projects' it_behaves_like 'response is correct', schema: 'public_api/v4/projects'
...@@ -155,7 +155,7 @@ describe API::Search do ...@@ -155,7 +155,7 @@ describe API::Search do
before do before do
create(:issue, project: project, title: 'awesome issue') create(:issue, project: project, title: 'awesome issue')
get api("/groups/#{group.id}/-/search", user), scope: 'issues', search: 'awesome' get api("/groups/#{group.id}/search", user), scope: 'issues', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/issues' it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
...@@ -165,7 +165,7 @@ describe API::Search do ...@@ -165,7 +165,7 @@ describe API::Search do
before do before do
create(:merge_request, source_project: repo_project, title: 'awesome mr') create(:merge_request, source_project: repo_project, title: 'awesome mr')
get api("/groups/#{group.id}/-/search", user), scope: 'merge_requests', search: 'awesome' get api("/groups/#{group.id}/search", user), scope: 'merge_requests', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests' it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
...@@ -175,7 +175,7 @@ describe API::Search do ...@@ -175,7 +175,7 @@ describe API::Search do
before do before do
create(:milestone, project: project, title: 'awesome milestone') create(:milestone, project: project, title: 'awesome milestone')
get api("/groups/#{group.id}/-/search", user), scope: 'milestones', search: 'awesome' get api("/groups/#{group.id}/search", user), scope: 'milestones', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
...@@ -187,7 +187,7 @@ describe API::Search do ...@@ -187,7 +187,7 @@ describe API::Search do
create(:milestone, project: project, title: 'awesome milestone') create(:milestone, project: project, title: 'awesome milestone')
create(:milestone, project: another_project, title: 'awesome milestone other project') create(:milestone, project: another_project, title: 'awesome milestone other project')
get api("/groups/#{CGI.escape(group.full_path)}/-/search", user), scope: 'milestones', search: 'awesome' get api("/groups/#{CGI.escape(group.full_path)}/search", user), scope: 'milestones', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
...@@ -198,7 +198,7 @@ describe API::Search do ...@@ -198,7 +198,7 @@ describe API::Search do
describe "GET /projects/:id/search" do describe "GET /projects/:id/search" do
context 'when user is not authenticated' do context 'when user is not authenticated' do
it 'returns 401 error' do it 'returns 401 error' do
get api("/projects/#{project.id}/-/search"), scope: 'issues', search: 'awesome' get api("/projects/#{project.id}/search"), scope: 'issues', search: 'awesome'
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(401)
end end
...@@ -206,7 +206,7 @@ describe API::Search do ...@@ -206,7 +206,7 @@ describe API::Search do
context 'when scope is not supported' do context 'when scope is not supported' do
it 'returns 400 error' do it 'returns 400 error' do
get api("/projects/#{project.id}/-/search", user), scope: 'unsupported', search: 'awesome' get api("/projects/#{project.id}/search", user), scope: 'unsupported', search: 'awesome'
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
...@@ -214,7 +214,7 @@ describe API::Search do ...@@ -214,7 +214,7 @@ describe API::Search do
context 'when scope is missing' do context 'when scope is missing' do
it 'returns 400 error' do it 'returns 400 error' do
get api("/projects/#{project.id}/-/search", user), search: 'awesome' get api("/projects/#{project.id}/search", user), search: 'awesome'
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
...@@ -222,7 +222,7 @@ describe API::Search do ...@@ -222,7 +222,7 @@ describe API::Search do
context 'when project does not exist' do context 'when project does not exist' do
it 'returns 404 error' do it 'returns 404 error' do
get api('/projects/9999/-/search', user), scope: 'issues', search: 'awesome' get api('/projects/9999/search', user), scope: 'issues', search: 'awesome'
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
end end
...@@ -232,7 +232,7 @@ describe API::Search do ...@@ -232,7 +232,7 @@ describe API::Search do
it 'returns 404 error' do it 'returns 404 error' do
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
get api("/projects/#{project.id}/-/search", user), scope: 'issues', search: 'awesome' get api("/projects/#{project.id}/search", user), scope: 'issues', search: 'awesome'
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
end end
...@@ -243,7 +243,7 @@ describe API::Search do ...@@ -243,7 +243,7 @@ describe API::Search do
before do before do
create(:issue, project: project, title: 'awesome issue') create(:issue, project: project, title: 'awesome issue')
get api("/projects/#{project.id}/-/search", user), scope: 'issues', search: 'awesome' get api("/projects/#{project.id}/search", user), scope: 'issues', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/issues' it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
...@@ -253,7 +253,7 @@ describe API::Search do ...@@ -253,7 +253,7 @@ describe API::Search do
before do before do
create(:merge_request, source_project: repo_project, title: 'awesome mr') create(:merge_request, source_project: repo_project, title: 'awesome mr')
get api("/projects/#{repo_project.id}/-/search", user), scope: 'merge_requests', search: 'awesome' get api("/projects/#{repo_project.id}/search", user), scope: 'merge_requests', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests' it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
...@@ -263,7 +263,7 @@ describe API::Search do ...@@ -263,7 +263,7 @@ describe API::Search do
before do before do
create(:milestone, project: project, title: 'awesome milestone') create(:milestone, project: project, title: 'awesome milestone')
get api("/projects/#{project.id}/-/search", user), scope: 'milestones', search: 'awesome' get api("/projects/#{project.id}/search", user), scope: 'milestones', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
...@@ -273,7 +273,7 @@ describe API::Search do ...@@ -273,7 +273,7 @@ describe API::Search do
before do before do
create(:note_on_merge_request, project: project, note: 'awesome note') create(:note_on_merge_request, project: project, note: 'awesome note')
get api("/projects/#{project.id}/-/search", user), scope: 'notes', search: 'awesome' get api("/projects/#{project.id}/search", user), scope: 'notes', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/notes' it_behaves_like 'response is correct', schema: 'public_api/v4/notes'
...@@ -284,7 +284,7 @@ describe API::Search do ...@@ -284,7 +284,7 @@ describe API::Search do
wiki = create(:project_wiki, project: project) wiki = create(:project_wiki, project: project)
create(:wiki_page, wiki: wiki, attrs: { title: 'home', content: "Awesome page" }) create(:wiki_page, wiki: wiki, attrs: { title: 'home', content: "Awesome page" })
get api("/projects/#{project.id}/-/search", user), scope: 'wiki_blobs', search: 'awesome' get api("/projects/#{project.id}/search", user), scope: 'wiki_blobs', search: 'awesome'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/blobs' it_behaves_like 'response is correct', schema: 'public_api/v4/blobs'
...@@ -292,7 +292,7 @@ describe API::Search do ...@@ -292,7 +292,7 @@ describe API::Search do
context 'for commits scope' do context 'for commits scope' do
before do before do
get api("/projects/#{repo_project.id}/-/search", user), scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6' get api("/projects/#{repo_project.id}/search", user), scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details' it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
...@@ -300,7 +300,7 @@ describe API::Search do ...@@ -300,7 +300,7 @@ describe API::Search do
context 'for commits scope with project path as id' do context 'for commits scope with project path as id' do
before do before do
get api("/projects/#{CGI.escape(repo_project.full_path)}/-/search", user), scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6' get api("/projects/#{CGI.escape(repo_project.full_path)}/search", user), scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details' it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
...@@ -308,7 +308,7 @@ describe API::Search do ...@@ -308,7 +308,7 @@ describe API::Search do
context 'for blobs scope' do context 'for blobs scope' do
before do before do
get api("/projects/#{repo_project.id}/-/search", user), scope: 'blobs', search: 'monitors' get api("/projects/#{repo_project.id}/search", user), scope: 'blobs', search: 'monitors'
end end
it_behaves_like 'response is correct', schema: 'public_api/v4/blobs', size: 2 it_behaves_like 'response is correct', schema: 'public_api/v4/blobs', size: 2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment