Commit 627815f1 authored by Dylan Griffith's avatar Dylan Griffith

Add spec for advanced queries

This should help prevent regressions like
https://gitlab.com/gitlab-org/gitlab/-/issues/213265
parent 55f03a2a
......@@ -45,5 +45,53 @@ RSpec.shared_examples 'EE search service shared examples' do |normal_results, el
is_expected.to be_a(normal_results)
end
context 'advanced syntax queries for all scopes', :elastic, :sidekiq_inline do
queries = [
'"display bug"',
'bug -display',
'bug display | sound',
'bug | (display +sound)',
'bug find_by_*',
'argument \-last'
]
scopes = if elasticsearch_results == ::Gitlab::Elastic::SnippetSearchResults
%w[
snippet_titles
snippet_blobs
]
else
%w[
merge_requests
notes
commits
blobs
projects
issues
wiki_blobs
milestones
]
end
queries.each do |query|
scopes.each do |scope|
context "with query #{query} and scope #{scope}" do
let(:params) { { search: query, scope: scope } }
it "allows advanced query" do
allow(Gitlab::CurrentSettings)
.to receive(:search_using_elasticsearch?)
.and_return(true)
ensure_elasticsearch_index!
results = subject
expect(results.objects(scope)).to be_kind_of(Enumerable)
end
end
end
end
end
end
end
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