Commit 06c5a2db authored by Jarka Kadlecová's avatar Jarka Kadlecová

API - fix searching in group/project specified by path

# Conflicts:
#	lib/api/search.rb
#	spec/requests/api/search_spec.rb
parent 5ceb0c6d
...@@ -109,9 +109,9 @@ module API ...@@ -109,9 +109,9 @@ module API
end end
get ':id/-/search' do get ':id/-/search' do
check_elasticsearch_scope! check_elasticsearch_scope!
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
end end
...@@ -130,9 +130,9 @@ module API ...@@ -130,9 +130,9 @@ module API
use :pagination use :pagination
end end
get ':id/-/search' do 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 end
end end
......
...@@ -265,7 +265,19 @@ describe API::Search do ...@@ -265,7 +265,19 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
end end
context 'when elasticsearch is enabled' do 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
context 'when elasticsearch is disabled' do
it_behaves_like 'elasticsearch disabled' do it_behaves_like 'elasticsearch disabled' do
let(:endpoint) { "/groups/#{group.id}/-/search" } let(:endpoint) { "/groups/#{group.id}/-/search" }
end end
...@@ -382,6 +394,14 @@ describe API::Search do ...@@ -382,6 +394,14 @@ describe API::Search do
it_behaves_like 'response is correct', schema: 'public_api/v4/commits' it_behaves_like 'response is correct', schema: 'public_api/v4/commits'
end 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 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'
......
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