Add backend code for searching posts with images.

This commit is contained in:
Jakub Macina 2017-06-07 20:13:36 +02:00
parent 8f7d81fde6
commit 76712da166
2 changed files with 7 additions and 2 deletions

View File

@ -338,6 +338,10 @@ class Search
end
end
advanced_filter(/in:image/) do |posts|
posts.where("posts.image_url IS NOT NULL")
end
advanced_filter(/category:(.+)/) do |posts,match|
exact = false

View File

@ -632,8 +632,9 @@ describe Search do
post_uploaded = Fabricate(:post_with_uploaded_image)
post_with_image_urls = Fabricate(:post_with_image_urls)
Fabricate(:post)
TopicLink.extract_from(post_uploaded)
TopicLink.extract_from(post_with_image_urls)
CookedPostProcessor.new(post_uploaded).update_post_image
CookedPostProcessor.new(post_with_image_urls).update_post_image
expect(Search.execute('in:image').posts.map(&:id).sort).to eq([post_uploaded.id, post_with_image_urls.id].sort)
end