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:
Robin Ward
2013-05-22 14:36:14 -04:00
parent 0f296cd42b
commit b9a310f4b1
4 changed files with 241 additions and 227 deletions

View File

@ -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