Commit a1f68852 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Fix limits when ES search isn't enabled globally

parent fa8aa600
...@@ -68,7 +68,7 @@ class SearchController < ApplicationController ...@@ -68,7 +68,7 @@ class SearchController < ApplicationController
private private
def search_term_valid? def search_term_valid?
return true if Gitlab::CurrentSettings.elasticsearch_search? return true if Gitlab::CurrentSettings.elasticsearch_search? && search_service.try(:use_elasticsearch?)
chars_count = params[:search].length chars_count = params[:search].length
if chars_count > NON_ES_SEARCH_CHAR_LIMIT if chars_count > NON_ES_SEARCH_CHAR_LIMIT
......
...@@ -116,21 +116,15 @@ describe SearchController do ...@@ -116,21 +116,15 @@ describe SearchController do
} }
end end
where(:es_enabled, :string_name, :expectation) do where(:string_name, :expectation) do
true | :chars_under_limit | :not_to_set_flash :chars_under_limit | :not_to_set_flash
true | :chars_over_limit | :not_to_set_flash :chars_over_limit | :set_chars_flash
true | :terms_under_limit | :not_to_set_flash :terms_under_limit | :not_to_set_flash
true | :terms_over_limit | :not_to_set_flash :terms_over_limit | :set_terms_flash
false | :chars_under_limit | :not_to_set_flash
false | :chars_over_limit | :set_chars_flash
false | :terms_under_limit | :not_to_set_flash
false | :terms_over_limit | :set_terms_flash
end end
with_them do with_them do
it do it do
allow(Gitlab::CurrentSettings).to receive(:elasticsearch_search?).and_return(es_enabled)
get :show, params: { scope: 'projects', search: search_queries[string_name] } get :show, params: { scope: 'projects', search: search_queries[string_name] }
case expectation case expectation
......
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