Can search by URL or ID

This commit is contained in:
Robin Ward
2013-05-13 17:04:41 -04:00
parent 957d95c1cc
commit fff46cf5aa
2 changed files with 86 additions and 41 deletions

View File

@ -110,7 +110,6 @@ describe Search do
let(:topic) { Fabricate(:topic) }
context 'searching the OP' do
let!(:post) { Fabricate(:post, topic: topic, user: topic.user) }
let(:result) { first_of_type(Search.query('hello', nil), 'topic') }
@ -119,7 +118,26 @@ describe Search do
result['title'].should == topic.title
result['url'].should == topic.relative_url
end
end
context "search for a topic by id" do
let(:result) { first_of_type(Search.query(topic.id, nil, 'topic'), 'topic') }
it 'returns the topic' do
result.should be_present
result['title'].should == topic.title
result['url'].should == topic.relative_url
end
end
context "search for a topic by url" do
let(:result) { first_of_type(Search.query(topic.relative_url, nil, 'topic'), 'topic') }
it 'returns the topic' do
result.should be_present
result['title'].should == topic.title
result['url'].should == topic.relative_url
end
end
context 'security' do