Add backend code for searching posts with images.
This commit is contained in:
parent
8f7d81fde6
commit
76712da166
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue