FIX: raises an error if q param is empty in search page
This commit is contained in:
parent
400eea4d13
commit
e7e4074856
|
@ -9,8 +9,8 @@ class SearchController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@search_term = params.require(:q)
|
||||
raise Discourse::InvalidParameters.new(:q) if @search_term.length < SiteSetting.min_search_term_length
|
||||
@search_term = params[:q]
|
||||
raise Discourse::InvalidParameters.new(:q) if @search_term.present? && @search_term.length < SiteSetting.min_search_term_length
|
||||
|
||||
search_args = {
|
||||
type_filter: 'topic',
|
||||
|
|
|
@ -127,6 +127,11 @@ describe SearchController do
|
|||
end
|
||||
|
||||
context "#show" do
|
||||
it "doesn't raise an error when search term not specified" do
|
||||
get "/search"
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "raises an error when the search term length is less than required" do
|
||||
get "/search.json", params: { q: 'ba' }
|
||||
expect(response.status).to eq(400)
|
||||
|
|
Loading…
Reference in New Issue