can't find staged users with search

This commit is contained in:
Régis Hanol 2015-11-18 21:06:59 +01:00
parent ff10eb32a6
commit 8ba5397f0d
2 changed files with 13 additions and 2 deletions

View File

@ -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")

View File

@ -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