Commit 15736451 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'ee-api-delimiter' into 'master'

[EE] Optional '/-/' delimiter for epics and search API

Closes #5245

See merge request gitlab-org/gitlab-ee!4973
parents 81503c33 6ea8fc2f
......@@ -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.
```
GET /groups/:id/-/epics/:epic_iid/issues
GET /groups/:id/epics/:epic_iid/issues
```
| Attribute | Type | Required | Description |
......@@ -19,7 +19,7 @@ GET /groups/:id/-/epics/:epic_iid/issues
| `epic_iid` | integer/string | yes | The internal ID of the epic. |
```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:
......@@ -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.
```
POST /groups/:id/-/epics/:epic_iid/issues/:issue_id
POST /groups/:id/epics/:epic_iid/issues/:issue_id
```
| Attribute | Type | Required | Description |
......@@ -116,7 +116,7 @@ POST /groups/:id/-/epics/:epic_iid/issues/:issue_id
| `issue_id` | integer/string | yes | The ID of the issue. |
```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:
......@@ -212,7 +212,7 @@ Example response:
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 |
......@@ -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. |
```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:
......@@ -318,7 +318,7 @@ Example response:
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 |
......@@ -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. |
```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:
......
......@@ -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.
```
GET /groups/:id/-/epics
GET /groups/:id/-/epics?author_id=5
GET /groups/:id/-/epics?labels=bug,reproduced
GET /groups/:id/epics
GET /groups/:id/epics?author_id=5
GET /groups/:id/epics?labels=bug,reproduced
```
| Attribute | Type | Required | Description |
......@@ -30,7 +30,7 @@ GET /groups/:id/-/epics?labels=bug,reproduced
| `search` | string | no | Search epics against their `title` and `description` |
```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:
......@@ -65,7 +65,7 @@ Example response:
Gets a single epic
```
GET /groups/:id/-/epics/:epic_iid
GET /groups/:id/epics/:epic_iid
```
| Attribute | Type | Required | Description |
......@@ -74,7 +74,7 @@ GET /groups/:id/-/epics/:epic_iid
| `epic_iid` | integer/string | yes | The internal ID of the epic. |
```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:
......@@ -106,7 +106,7 @@ Example response:
Creates a new epic
```
POST /groups/:id/-/epics
POST /groups/:id/epics
```
| Attribute | Type | Required | Description |
......@@ -119,7 +119,7 @@ POST /groups/:id/-/epics
| `end_date` | string. | no | The end date of the epic |
```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:
......@@ -152,7 +152,7 @@ Example response:
Updates an epic
```
PUT /groups/:id/-/epics/:epic_iid
PUT /groups/:id/epics/:epic_iid
```
| Attribute | Type | Required | Description |
......@@ -166,7 +166,7 @@ PUT /groups/:id/-/epics/:epic_iid
| `end_date` | string. | no | The end date of an epic |
```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:
......@@ -199,7 +199,7 @@ Example response:
Deletes an epic
```
DELETE /groups/:id/-/epics/:epic_iid
DELETE /groups/:id/epics/:epic_iid
```
| Attribute | Type | Required | Description |
......@@ -208,5 +208,5 @@ DELETE /groups/:id/-/epics/:epic_iid
| `epic_iid` | integer/string | yes | The internal ID of the epic. |
```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.
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 |
......@@ -392,7 +392,7 @@ The response depends on the requested scope.
### Scope: projects
```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:
......@@ -423,7 +423,7 @@ Example response:
### Scope: issues
```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:
......@@ -488,7 +488,7 @@ Example response:
### Scope: merge_requests
```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:
......@@ -565,7 +565,7 @@ Example response:
### Scope: milestones
```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:
......@@ -592,7 +592,7 @@ Example response:
This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled.
```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:
......@@ -617,7 +617,7 @@ Example response:
This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled.
```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:
......@@ -650,7 +650,7 @@ Example response:
This scope is available only if [Elasticsearch](../integration/elasticsearch.md) is enabled.
```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:
......@@ -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.
```
GET /projects/:id/-/search
GET /projects/:id/search
```
| Attribute | Type | Required | Description |
......@@ -694,7 +694,7 @@ The response depends on the requested scope.
### Scope: issues
```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:
......@@ -759,7 +759,7 @@ Example response:
### Scope: merge_requests
```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:
......@@ -836,7 +836,7 @@ Example response:
### Scope: milestones
```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:
......@@ -861,7 +861,7 @@ Example response:
### Scope: notes
```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:
......@@ -893,7 +893,7 @@ Example response:
### Scope: wiki_blobs
```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:
......@@ -916,7 +916,7 @@ Example response:
### Scope: commits
```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:
......@@ -947,7 +947,7 @@ Example response:
### Scope: blobs
```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:
......
---
title: Make /-/ delimiter optional for epics and search endpoints
merge_request:
author:
type: changed
......@@ -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_after_id, type: Integer, desc: 'The id of the epic issue association that should be positioned after the actual issue'
end
put ':id/-/epics/:epic_iid/issues/:epic_issue_id' do
put ':id/(-/)epics/:epic_iid/issues/:epic_issue_id' do
authorize_can_admin!
update_params = {
......@@ -67,7 +67,7 @@ module API
params do
requires :epic_iid, type: Integer, desc: 'The iid of the epic'
end
get ':id/-/epics/:epic_iid/issues' do
get ':id/(-/)epics/:epic_iid/issues' do
authorize_can_read!
present epic.issues(current_user),
......@@ -81,7 +81,7 @@ module API
params do
requires :epic_iid, type: Integer, desc: 'The iid of the epic'
end
post ':id/-/epics/:epic_iid/issues/:issue_id' do
post ':id/(-/)epics/:epic_iid/issues/:issue_id' do
authorize_can_admin!
issue = Issue.find(params[:issue_id])
......@@ -106,7 +106,7 @@ module API
requires :epic_iid, type: Integer, desc: 'The iid of the epic'
requires :epic_issue_id, type: Integer, desc: 'The id of the association'
end
delete ':id/-/epics/:epic_iid/issues/:epic_issue_id' do
delete ':id/(-/)epics/:epic_iid/issues/:epic_issue_id' do
authorize_can_admin!
result = ::EpicIssues::DestroyService.new(link, current_user).execute
......
......@@ -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 :labels, type: String, desc: 'Comma-separated list of label names'
end
get ':id/-/epics' do
get ':id/(-/)epics' do
present find_epics(group_id: user_group.id), with: EE::API::Entities::Epic
end
......@@ -67,7 +67,7 @@ module API
params do
requires :epic_iid, type: Integer, desc: 'The internal ID of an epic'
end
get ':id/-/epics/:epic_iid' do
get ':id/(-/)epics/:epic_iid' do
authorize_can_read!
present epic, with: EE::API::Entities::Epic
......@@ -83,7 +83,7 @@ module API
optional :end_date, type: String, desc: 'The end date of an epic'
optional :labels, type: String, desc: 'Comma-separated list of label names'
end
post ':id/-/epics' do
post ':id/(-/)epics' do
authorize_can_create!
epic = ::Epics::CreateService.new(user_group, current_user, declared_params(include_missing: false)).execute
......@@ -106,7 +106,7 @@ module API
optional :labels, type: String, desc: 'Comma-separated list of label names'
at_least_one_of :title, :description, :start_date, :end_date, :labels
end
put ':id/-/epics/:epic_iid' do
put ':id/(-/)epics/:epic_iid' do
authorize_can_admin!
update_params = declared_params(include_missing: false)
update_params.delete(:epic_iid)
......@@ -126,7 +126,7 @@ module API
params do
requires :epic_iid, type: Integer, desc: 'The internal ID of an epic'
end
delete ':id/-/epics/:epic_iid' do
delete ':id/(-/)epics/:epic_iid' do
authorize_can_destroy!
Issuable::DestroyService.new(nil, current_user).execute(epic)
......
......@@ -6,8 +6,8 @@ describe API::EpicIssues do
let(:project) { create(:project, :public, group: group) }
let(:epic) { create(:epic, group: group) }
describe 'GET /groups/:id/-/epics/:epic_iid/issues' do
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}/issues" }
describe 'GET /groups/:id/epics/:epic_iid/issues' do
let(:url) { "/groups/#{group.path}/epics/#{epic.iid}/issues" }
context 'when epics feature is disabled' do
it 'returns 403 forbidden error' do
......@@ -61,9 +61,9 @@ describe API::EpicIssues do
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(: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
it 'returns 403 forbidden error' do
......@@ -145,10 +145,10 @@ describe API::EpicIssues do
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!(: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
it 'returns 403 forbidden error' do
......@@ -229,12 +229,12 @@ describe API::EpicIssues do
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!(: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(: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
it 'returns 403 forbidden error' do
......@@ -274,7 +274,7 @@ describe API::EpicIssues do
it 'returns 404 not found error for the link of another epic' do
group.add_developer(user)
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)
......
......@@ -40,8 +40,8 @@ describe API::Epics do
end
end
describe 'GET /groups/:id/-/epics' do
let(:url) { "/groups/#{group.path}/-/epics" }
describe 'GET /groups/:id/epics' do
let(:url) { "/groups/#{group.path}/epics" }
it_behaves_like 'error requests'
......@@ -141,8 +141,8 @@ describe API::Epics do
end
end
describe 'GET /groups/:id/-/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}" }
describe 'GET /groups/:id/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/epics/#{epic.iid}" }
it_behaves_like 'error requests'
......@@ -163,8 +163,8 @@ describe API::Epics do
end
end
describe 'POST /groups/:id/-/epics' do
let(:url) { "/groups/#{group.path}/-/epics" }
describe 'POST /groups/:id/epics' do
let(:url) { "/groups/#{group.path}/epics" }
let(:params) { { title: 'new epic', description: 'epic description', labels: 'label1' } }
it_behaves_like 'error requests'
......@@ -210,8 +210,8 @@ describe API::Epics do
end
end
describe 'PUT /groups/:id/-/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}" }
describe 'PUT /groups/:id/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/epics/#{epic.iid}" }
let(:params) { { title: 'new title', description: 'new description', labels: 'label2' } }
it_behaves_like 'error requests'
......@@ -265,8 +265,8 @@ describe API::Epics do
end
end
describe 'DELETE /groups/:id/-/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/-/epics/#{epic.iid}" }
describe 'DELETE /groups/:id/epics/:epic_iid' do
let(:url) { "/groups/#{group.path}/epics/#{epic.iid}" }
it_behaves_like 'error requests'
......
......@@ -107,7 +107,7 @@ module API
values: %w(projects issues merge_requests milestones wiki_blobs blobs commits)
use :pagination
end
get ':id/-/search' do
get ':id/(-/)search' do
check_elasticsearch_scope!
present search(group_id: user_group.id), with: entity
......@@ -128,7 +128,7 @@ module API
values: %w(issues merge_requests milestones notes wiki_blobs commits blobs)
use :pagination
end
get ':id/-/search' do
get ':id/(-/)search' do
present search(project_id: user_project.id), with: entity
end
end
......
......@@ -99,10 +99,10 @@ describe API::Search do
end
end
describe "GET /groups/:id/-/search" do
describe "GET /groups/:id/search" do
context 'when user is not authenticated' 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)
end
......@@ -110,7 +110,7 @@ describe API::Search do
context 'when scope is not supported' 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)
end
......@@ -118,7 +118,7 @@ describe API::Search do
context 'when scope is missing' 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)
end
......@@ -126,7 +126,7 @@ describe API::Search do
context 'when group does not exist' 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)
end
......@@ -136,7 +136,7 @@ describe API::Search do
it 'returns 404 error' do
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)
end
......@@ -145,7 +145,7 @@ describe API::Search do
context 'with correct params' do
context 'for projects scope' 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
it_behaves_like 'response is correct', schema: 'public_api/v4/projects'
......@@ -155,7 +155,7 @@ describe API::Search do
before do
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
it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
......@@ -165,7 +165,7 @@ describe API::Search do
before do
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
it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
......@@ -175,7 +175,7 @@ describe API::Search do
before do
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
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
......@@ -187,7 +187,7 @@ describe API::Search do
create(:milestone, project: project, title: 'awesome milestone')
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
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
......@@ -198,7 +198,7 @@ describe API::Search do
describe "GET /projects/:id/search" do
context 'when user is not authenticated' 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)
end
......@@ -206,7 +206,7 @@ describe API::Search do
context 'when scope is not supported' 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)
end
......@@ -214,7 +214,7 @@ describe API::Search do
context 'when scope is missing' 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)
end
......@@ -222,7 +222,7 @@ describe API::Search do
context 'when project does not exist' 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)
end
......@@ -232,7 +232,7 @@ describe API::Search do
it 'returns 404 error' do
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)
end
......@@ -243,7 +243,7 @@ describe API::Search do
before do
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
it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
......@@ -253,7 +253,7 @@ describe API::Search do
before do
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
it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
......@@ -263,7 +263,7 @@ describe API::Search do
before do
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
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
......@@ -273,7 +273,7 @@ describe API::Search do
before do
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
it_behaves_like 'response is correct', schema: 'public_api/v4/notes'
......@@ -284,7 +284,7 @@ describe API::Search do
wiki = create(:project_wiki, project: project)
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
it_behaves_like 'response is correct', schema: 'public_api/v4/blobs'
......@@ -292,7 +292,7 @@ describe API::Search do
context 'for commits scope' 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
it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
......@@ -300,7 +300,7 @@ describe API::Search do
context 'for commits scope with project path as id' 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
it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
......@@ -308,7 +308,7 @@ describe API::Search do
context 'for blobs scope' 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
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