mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
FIX: raises an error if q param is empty in search page
This commit is contained in:
parent
400eea4d13
commit
e7e4074856
2 changed files with 7 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue