mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FIX: username autocomplete in assign modal wasn't working
This commit is contained in:
parent
5b96463c40
commit
daf1dda700
@ -706,8 +706,10 @@ class UsersController < ApplicationController
|
||||
Group.messageable(current_user)
|
||||
end
|
||||
|
||||
to_render[:groups] = groups.where("name ILIKE :term_like", term_like: "#{term}%")
|
||||
.map { |m| { name: m.name, full_name: m.full_name } }
|
||||
if groups
|
||||
to_render[:groups] = groups.where("name ILIKE :term_like", term_like: "#{term}%")
|
||||
.map { |m| { name: m.name, full_name: m.full_name } }
|
||||
end
|
||||
end
|
||||
|
||||
render json: to_render
|
||||
|
@ -175,6 +175,16 @@ RSpec.describe UsersController do
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
it "doesn't search for groups" do
|
||||
get "/u/search/users.json", params: {
|
||||
include_mentionable_groups: 'false',
|
||||
include_messageable_groups: 'false'
|
||||
}
|
||||
|
||||
expect(response).to be_success
|
||||
expect(JSON.parse(response.body)).not_to have_key(:groups)
|
||||
end
|
||||
|
||||
it "searches for messageable groups" do
|
||||
get "/u/search/users.json", params: {
|
||||
include_mentionable_groups: 'false',
|
||||
@ -198,13 +208,21 @@ RSpec.describe UsersController do
|
||||
|
||||
describe 'when not signed in' do
|
||||
it 'should not include mentionable/messageable groups' do
|
||||
get "/u/search/users.json", params: {
|
||||
include_mentionable_groups: 'false',
|
||||
include_messageable_groups: 'false'
|
||||
}
|
||||
|
||||
expect(response).to be_success
|
||||
expect(JSON.parse(response.body)).not_to have_key(:groups)
|
||||
|
||||
get "/u/search/users.json", params: {
|
||||
include_mentionable_groups: 'false',
|
||||
include_messageable_groups: 'true'
|
||||
}
|
||||
|
||||
expect(response).to be_success
|
||||
expect(JSON.parse(response.body)["groups"]).to eq(nil)
|
||||
expect(JSON.parse(response.body)).not_to have_key(:groups)
|
||||
|
||||
get "/u/search/users.json", params: {
|
||||
include_messageable_groups: 'false',
|
||||
@ -212,7 +230,7 @@ RSpec.describe UsersController do
|
||||
}
|
||||
|
||||
expect(response).to be_success
|
||||
expect(JSON.parse(response.body)["groups"]).to eq(nil)
|
||||
expect(JSON.parse(response.body)).not_to have_key(:groups)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user