Commit 42fbae52 authored by Brett Walker's avatar Brett Walker Committed by Heinrich Lee Yu

Add specs to IssueFinder

parent 5b7fd663
...@@ -567,6 +567,31 @@ RSpec.describe IssuesFinder do ...@@ -567,6 +567,31 @@ RSpec.describe IssuesFinder do
it 'returns issues with title and description match for search term' do it 'returns issues with title and description match for search term' do
expect(issues).to contain_exactly(issue1, issue2) expect(issues).to contain_exactly(issue1, issue2)
end end
context 'with anonymous user' do
let_it_be(:public_project, reload: true) { create(:project, :public, group: subgroup) }
let_it_be(:issue6, reload: true) { create(:issue, project: public_project, title: 'tanuki') }
let_it_be(:issue7, reload: true) { create(:issue, project: public_project, title: 'ikunat') }
let(:search_user) { nil }
let(:params) { { search: 'tanuki' } }
context 'with disable_anonymous_search feature flag enabled' do
it 'does not perform search' do
expect(issues).to contain_exactly(issue6, issue7)
end
end
context 'with disable_anonymous_search feature flag disabled' do
before do
stub_feature_flags(disable_anonymous_search: false)
end
it 'finds one public issue' do
expect(issues).to contain_exactly(issue6)
end
end
end
end end
context 'filtering by issue term in title' do context 'filtering by issue term in title' do
...@@ -1256,7 +1281,7 @@ RSpec.describe IssuesFinder do ...@@ -1256,7 +1281,7 @@ RSpec.describe IssuesFinder do
end end
describe '#use_cte_for_search?' do describe '#use_cte_for_search?' do
let(:finder) { described_class.new(nil, params) } let(:finder) { described_class.new(user, params) }
context 'when there is no search param' do context 'when there is no search param' do
let(:params) { { attempt_group_search_optimizations: true } } let(:params) { { attempt_group_search_optimizations: true } }
...@@ -1275,7 +1300,7 @@ RSpec.describe IssuesFinder do ...@@ -1275,7 +1300,7 @@ RSpec.describe IssuesFinder do
end end
context 'when all conditions are met' do context 'when all conditions are met' do
context "uses group search optimization" do context 'uses group search optimization' do
let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
it 'returns true' do it 'returns true' do
...@@ -1284,7 +1309,7 @@ RSpec.describe IssuesFinder do ...@@ -1284,7 +1309,7 @@ RSpec.describe IssuesFinder do
end end
end end
context "uses project search optimization" do context 'uses project search optimization' do
let(:params) { { search: 'foo', attempt_project_search_optimizations: true } } let(:params) { { search: 'foo', attempt_project_search_optimizations: true } }
it 'returns true' do it 'returns true' do
......
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