mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: only show approved users in search_user results when site setting enabled (#20493)
Returns only approved users when using @ in composer (if must_approve_users site setting enabled).
This commit is contained in:
parent
44b7706a2b
commit
8a2995f719
|
@ -26,6 +26,7 @@ class UserSearch
|
|||
|
||||
def scoped_users
|
||||
users = User.where(active: true)
|
||||
users = users.where(approved: true) if SiteSetting.must_approve_users?
|
||||
users = users.where(staged: false) unless @include_staged_users
|
||||
users = users.not_suspended unless @searching_user&.staff?
|
||||
|
||||
|
|
|
@ -226,6 +226,18 @@ RSpec.describe UserSearch do
|
|||
expect(results).to be_blank
|
||||
end
|
||||
|
||||
it "does not show unapproved users when must_approve_users enabled" do
|
||||
SiteSetting.must_approve_users = true
|
||||
unapproved = Fabricate(:user, username: "mrunapproved", active: true, approved: false)
|
||||
approved = Fabricate(:user, username: "mrapproved", active: true, approved: true)
|
||||
|
||||
users = search_for(unapproved.username)
|
||||
expect(users).to be_blank
|
||||
|
||||
users = search_for(approved.username)
|
||||
expect(users).not_to be_blank
|
||||
end
|
||||
|
||||
it "prioritises exact matches" do
|
||||
results = search_for("mrB")
|
||||
expect(results).to eq [mr_b, mr_brown, mr_blue].map(&:username)
|
||||
|
|
Loading…
Reference in New Issue
Block a user