mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:01:26 +08:00
Search Refactor: Let's use a class to keep track of our state rather
than passing params everywhere. Also make the private API private.
This commit is contained in:
@ -3,16 +3,24 @@ require 'spec_helper'
|
||||
describe SearchController do
|
||||
|
||||
it 'performs the query' do
|
||||
m = Guardian.new(nil)
|
||||
Guardian.stubs(:new).returns(m)
|
||||
Search.expects(:query).with('test', m, nil, 3)
|
||||
guardian = Guardian.new
|
||||
Guardian.stubs(:new).returns(guardian)
|
||||
|
||||
search = mock()
|
||||
Search.expects(:new).with('test', guardian: guardian, type_filter: nil).returns(search)
|
||||
search.expects(:execute)
|
||||
|
||||
xhr :get, :query, term: 'test'
|
||||
end
|
||||
|
||||
it 'performs the query with a filter' do
|
||||
m = Guardian.new(nil)
|
||||
Guardian.stubs(:new).returns(m)
|
||||
Search.expects(:query).with('test', m, 'topic', 3)
|
||||
guardian = Guardian.new
|
||||
Guardian.stubs(:new).returns(guardian)
|
||||
|
||||
search = mock()
|
||||
Search.expects(:new).with('test', guardian: guardian, type_filter: 'topic').returns(search)
|
||||
search.expects(:execute)
|
||||
|
||||
xhr :get, :query, term: 'test', type_filter: 'topic'
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user