Commit fe56c85b authored by Dylan Griffith's avatar Dylan Griffith

Add feature flag for switch to basic search

parent 3a5b691b
......@@ -70,14 +70,13 @@ module EE
search_path(search_params)
end
# Switching to basic search should only be possible for a subset of
# scopes. This method assumes you're already allowed to search within
# this scope but it's just here to determine if you can switch to basic
# search.
def switch_to_basic_searchable_tab?(scope)
def show_switch_to_basic_search?(search_service)
return false unless ::Feature.enabled?(:switch_to_basic_search, default_enabled: false)
return false unless search_service.use_elasticsearch?
return true if @project
scope.in?(SWITCH_TO_BASIC_SEARCHABLE_TABS)
search_service.scope.in?(SWITCH_TO_BASIC_SEARCHABLE_TABS)
end
private
......
- if search_service.use_elasticsearch? && switch_to_basic_searchable_tab?(search_service.scope)
- if show_switch_to_basic_search?(search_service)
- begin_link = '<a href="%{url}">'.html_safe % { url: revert_to_basic_search_filter_url }
- end_link = '</a>'.html_safe
%p.text-center
......
......@@ -176,9 +176,29 @@ describe SearchHelper do
end
end
describe '#switch_to_basic_searchable_tab?' do
describe '#show_switch_to_basic_search?' do
let(:use_elasticsearch) { true }
let(:scope) { 'commits' }
subject { switch_to_basic_searchable_tab?(scope) }
let(:search_service) { instance_double(Search::GlobalService, use_elasticsearch?: use_elasticsearch, scope: scope) }
subject { show_switch_to_basic_search?(search_service) }
before do
stub_feature_flags(switch_to_basic_search: true)
end
context 'when :switch_to_basic_search feature is disabled' do
before do
stub_feature_flags(switch_to_basic_search: false)
end
it { is_expected.to eq(false) }
end
context 'when not currently using elasticsearch' do
let(:use_elasticsearch) { false }
it { is_expected.to eq(false) }
end
context 'when project scope' do
before 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