Commit d086bd98 authored by Jake Lear's avatar Jake Lear

Disable anonymous searching for ProjectsFinder by feature flag

parent 8a4b65c7
......@@ -193,6 +193,7 @@ class ProjectsFinder < UnionFinder
def by_search(items)
params[:search] ||= params[:name]
return items if Feature.enabled?(:disable_anonymous_search, type: :ops) && current_user.nil?
return items.none if params[:search].present? && params[:minimum_search_length].present? && params[:search].length < params[:minimum_search_length].to_i
items.optionally_search(params[:search], include_namespace: params[:search_namespaces].present?)
......
......@@ -190,6 +190,32 @@ RSpec.describe ProjectsFinder do
it { is_expected.to eq([public_project]) }
end
context 'with anonymous user' do
let(:public_project_2) { create(:project, :public, group: group, name: 'E', path: 'E') }
let(:current_user) { nil }
let(:params) { { search: 'C' } }
context 'with disable_anonymous_search feature flag enabled' do
before do
stub_feature_flags(disable_anonymous_search: true)
end
it 'does not perform search' do
is_expected.to eq([public_project_2, public_project])
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 project' do
is_expected.to eq([public_project])
end
end
end
describe 'filter by name for backward compatibility' do
let(:params) { { name: 'C' } }
......
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