Skip to content
Snippets Groups Projects
Unverified Commit 538b0f11 authored by Harsimar Sandhu's avatar Harsimar Sandhu Committed by GitLab
Browse files

Merge branch '287819-fix-conan-info-with-range' into 'master'

parents 51962052 7beb87aa
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -6,6 +6,7 @@ class SearchService < BaseService
include ActiveRecord::Sanitization::ClassMethods
 
WILDCARD = '*'
SLASH = '/'
 
def execute
ServiceResponse.success(payload: { results: search_results })
Loading
Loading
@@ -35,7 +36,7 @@ def search_packages
end
 
def build_query
return "#{sanitized_query}%" if params[:query].end_with?(WILDCARD)
return "#{sanitized_query}%" if params[:query].end_with?(WILDCARD) && !sanitized_query.end_with?(SLASH)
 
sanitized_query
end
Loading
Loading
Loading
Loading
@@ -24,6 +24,31 @@
end
end
 
context 'with query ending with /*' do
let(:query) { "#{conan_package.name}/*" }
it 'make a correct search without appending like operator' do
result = subject.execute
expect(result.status).to eq :success
expect(result.payload).to eq(results: [conan_package.conan_recipe])
end
end
context 'with query including username and version as *' do
let(:query) do
"#{conan_package.name}/*@#{conan_package.conan_metadatum.package_username}/" \
"#{conan_package.conan_metadatum.package_channel}"
end
it 'processes the query correctly' do
result = subject.execute
expect(result.status).to eq :success
expect(result.payload).to eq(results: [conan_package.conan_recipe])
end
end
context 'with only wildcard' do
let(:query) { '*' }
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment