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

Merge pull request #390 from ZogStriP/min-search-term-length-site-setting

added the min-search-term-length site setting
This commit is contained in:
Robin Ward 2013-03-08 06:58:45 -08:00
commit fb573b917f
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