2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-12 21:10:47 +08:00

added the min-search-term-length site setting

This commit is contained in:
Regis Hanol 2013-03-07 16:52:01 +01:00
parent 590bb2acac
commit 5703d6c730
8 changed files with 25 additions and 18 deletions

View file

@ -71,6 +71,11 @@ describe Search do
Search.query(nil).should be_blank
end

it 'does not search when the search term is too small' do
ActiveRecord::Base.expects(:exec_sql).never
Search.query('evil', nil, 5).should be_blank
end

it 'escapes non alphanumeric characters' do
Search.query('foo :!$);}]>@\#\"\'').should be_blank # There are at least three levels of sanitation for Search.query!
end

View file

@ -3,14 +3,13 @@ require 'spec_helper'
describe SearchController do

it 'performs the query' do
Search.expects(:query).with('test', nil)
Search.expects(:query).with('test', nil, 3)
xhr :get, :query, term: 'test'
end

it 'performs the query with a filter' do
Search.expects(:query).with('test', 'topic')
Search.expects(:query).with('test', 'topic', 3)
xhr :get, :query, term: 'test', type_filter: 'topic'
end


end