mirror of
https://github.com/discourse/discourse.git
synced 2025-02-18 17:25:15 +00:00
FIX: topic search wasn't working for unlisted topics
This commit is contained in:
parent
94163d7f1a
commit
a98aae3bcd
@ -660,10 +660,11 @@ class Search
|
||||
.joins(:post_search_data, :topic)
|
||||
.joins("LEFT JOIN categories ON categories.id = topics.category_id")
|
||||
.where("topics.deleted_at" => nil)
|
||||
.where("topics.visible")
|
||||
|
||||
is_topic_search = @search_context.present? && @search_context.is_a?(Topic)
|
||||
|
||||
posts = posts.where("topics.visible") unless is_topic_search
|
||||
|
||||
if opts[:private_messages] || (is_topic_search && @search_context.private_message?)
|
||||
posts = posts.where("topics.archetype = ?", Archetype.private_message)
|
||||
|
||||
|
@ -251,7 +251,6 @@ describe Search do
|
||||
end
|
||||
|
||||
it 'displays multiple results within a topic' do
|
||||
|
||||
topic = Fabricate(:topic)
|
||||
topic2 = Fabricate(:topic)
|
||||
|
||||
@ -260,8 +259,7 @@ describe Search do
|
||||
|
||||
post1 = new_post('this is the other post I am posting', topic)
|
||||
post2 = new_post('this is my first post I am posting', topic)
|
||||
post3 = new_post('this is a real long and complicated bla this is my second post I am Posting birds
|
||||
with more stuff bla bla', topic)
|
||||
post3 = new_post('this is a real long and complicated bla this is my second post I am Posting birds with more stuff bla bla', topic)
|
||||
post4 = new_post('this is my fourth post I am posting', topic)
|
||||
|
||||
# update posts_count
|
||||
@ -281,6 +279,13 @@ describe Search do
|
||||
results = Search.execute('"fourth post I am posting"', search_context: post1.topic)
|
||||
expect(results.posts.length).to eq(1)
|
||||
end
|
||||
|
||||
it "works for unlisted topics" do
|
||||
topic.update_attributes(visible: false)
|
||||
post = new_post('discourse is awesome', topic)
|
||||
results = Search.execute('discourse', search_context: topic)
|
||||
expect(results.posts.length).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'searching the OP' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user