FIX: Do not show hidden posts in search results (#26800)
This commit is contained in:
parent
f7a1272fa4
commit
9fb888923d
|
@ -1076,7 +1076,7 @@ class Search
|
||||||
|
|
||||||
def posts_query(limit, type_filter: nil, aggregate_search: false)
|
def posts_query(limit, type_filter: nil, aggregate_search: false)
|
||||||
posts =
|
posts =
|
||||||
Post.where(post_type: Topic.visible_post_types(@guardian.user)).joins(
|
Post.where(post_type: Topic.visible_post_types(@guardian.user), hidden: false).joins(
|
||||||
:post_search_data,
|
:post_search_data,
|
||||||
:topic,
|
:topic,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1026,6 +1026,13 @@ RSpec.describe Search do
|
||||||
expect(results.posts).to eq([post])
|
expect(results.posts).to eq([post])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not return hidden posts" do
|
||||||
|
Fabricate(:post, raw: "Can you see me? I'm a hidden post", hidden: true)
|
||||||
|
|
||||||
|
results = Search.execute("hidden post")
|
||||||
|
expect(results.posts.count).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
it "does not rely on postgres's proximity opreators" do
|
it "does not rely on postgres's proximity opreators" do
|
||||||
topic.update!(title: "End-to-end something something testing")
|
topic.update!(title: "End-to-end something something testing")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue