can't find staged users with search
This commit is contained in:
parent
ff10eb32a6
commit
8ba5397f0d
|
@ -243,7 +243,7 @@ class Search
|
|||
end
|
||||
|
||||
advanced_filter(/user:(.+)/) do |posts,match|
|
||||
user_id = User.where('username_lower = ? OR id = ?', match.downcase, match.to_i).pluck(:id).first
|
||||
user_id = User.where(staged: false).where('username_lower = ? OR id = ?', match.downcase, match.to_i).pluck(:id).first
|
||||
if user_id
|
||||
posts.where("posts.user_id = #{user_id}")
|
||||
else
|
||||
|
@ -383,7 +383,8 @@ class Search
|
|||
|
||||
users = User.includes(:user_search_data)
|
||||
.references(:user_search_data)
|
||||
.where("active = TRUE")
|
||||
.where(active: true)
|
||||
.where(staged: false)
|
||||
.where("user_search_data.search_data @@ #{ts_query("simple")}")
|
||||
.order("CASE WHEN username_lower = '#{@original_term.downcase}' THEN 0 ELSE 1 END")
|
||||
.order("last_posted_at DESC")
|
||||
|
|
|
@ -111,6 +111,15 @@ describe Search do
|
|||
end
|
||||
end
|
||||
|
||||
context 'staged users' do
|
||||
let(:staged) { Fabricate(:staged) }
|
||||
let(:result) { Search.execute(staged.username) }
|
||||
|
||||
it 'does not return a result' do
|
||||
expect(result.users.length).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'private messages' do
|
||||
|
||||
let(:topic) {
|
||||
|
@ -403,6 +412,7 @@ describe Search do
|
|||
|
||||
expect(Search.execute('user:nobody').posts.length).to eq(0)
|
||||
expect(Search.execute("user:#{_post.user.username}").posts.length).to eq(1)
|
||||
expect(Search.execute("user:#{_post.user_id}").posts.length).to eq(1)
|
||||
end
|
||||
|
||||
it 'supports group' do
|
||||
|
|
Loading…
Reference in New Issue