diff options
author | Jarka Kadlecová <jarka@gitlab.com> | 2018-02-09 15:38:52 +0100 |
---|---|---|
committer | Jarka Kadlecová <jarka@gitlab.com> | 2018-02-09 18:51:06 +0100 |
commit | 68ff219c4ec9088005ab872e141912f35ecc59f3 (patch) | |
tree | 039c8aef3959ce8c5ab2d7121aec4d3b122f0c95 | |
parent | fa0923ddfed657223d2e337693f4f2dc74cd7604 (diff) | |
download | gitlab-ce-68ff219c4ec9088005ab872e141912f35ecc59f3.tar.gz |
API - fix searching in group/project specified by path42937-search-api-fix
-rw-r--r-- | lib/api/search.rb | 8 | ||||
-rw-r--r-- | spec/requests/api/search_spec.rb | 20 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/api/search.rb b/lib/api/search.rb index 9f08fd96a3b..b9982e03bb3 100644 --- a/lib/api/search.rb +++ b/lib/api/search.rb @@ -85,9 +85,9 @@ module API use :pagination end get ':id/-/search' do - find_group!(params[:id]) + group = find_group!(params[:id]) - present search(group_id: params[:id]), with: entity + present search(group_id: group.id), with: entity end end @@ -106,9 +106,9 @@ module API use :pagination end get ':id/-/search' do - find_project!(params[:id]) + project = find_project!(params[:id]) - present search(project_id: params[:id]), with: entity + present search(project_id: project.id), with: entity end end end diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb index a0026c6e11c..ddda5752f0c 100644 --- a/spec/requests/api/search_spec.rb +++ b/spec/requests/api/search_spec.rb @@ -180,6 +180,18 @@ describe API::Search do it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' end + + context 'for milestones scope with group path as id' do + before do + another_project = create(:project, :public) + 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' + end + + it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' + end end end @@ -286,6 +298,14 @@ describe API::Search do it_behaves_like 'response is correct', schema: 'public_api/v4/commits' end + 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' + end + + it_behaves_like 'response is correct', schema: 'public_api/v4/commits' + end + context 'for blobs scope' do before do get api("/projects/#{repo_project.id}/-/search", user), scope: 'blobs', search: 'monitors' |