Add rspec tests for searching by a filetype.

This commit is contained in:
Jakub Macina 2017-06-20 21:21:56 +02:00
parent f87d32ac6d
commit aad1c9bef2
1 changed files with 18 additions and 0 deletions

View File

@ -703,6 +703,24 @@ describe Search do
expect(Search.execute('green tags:eggs').posts.map(&:id)).to eq([post2.id])
expect(Search.execute('green tags:plants').posts.size).to eq(0)
end
it "can find posts which contains filetypes" do
# Must be posts with real images
post1 = Fabricate(:post,
raw: "https://www.discourse.org/a/img/favicon.png")
post2 = Fabricate(:post,
raw: "Discourse logo\n"\
"https://www.discourse.org/a/img/favicon.png\n"\
"https://www.discourse.org/a/img/trust-1x.jpg")
Fabricate(:post)
TopicLink.extract_from(post1)
TopicLink.extract_from(post2)
expect(Search.execute('filetype:jpg').posts.map(&:id)).to eq([post2.id])
expect(Search.execute('filetype:png').posts.map(&:id)).to contain_exactly(post1.id, post2.id)
expect(Search.execute('logo filetype:jpg').posts.map(&:id)).to eq([post2.id])
end
end
it 'can parse complex strings using ts_query helper' do