mirror of
https://github.com/discourse/discourse.git
synced 2025-06-14 19:29:21 +08:00
FIX: Respond to user search correctly when category_id is blank
Previously it would search for category_id=0, which does not exist. With the new permission checks, this returns a 404
This commit is contained in:
@ -921,8 +921,7 @@ class UsersController < ApplicationController
|
|||||||
topic_id = params[:topic_id]
|
topic_id = params[:topic_id]
|
||||||
topic_id = topic_id.to_i if topic_id
|
topic_id = topic_id.to_i if topic_id
|
||||||
|
|
||||||
category_id = params[:category_id]
|
category_id = params[:category_id].to_i if category_id.present?
|
||||||
category_id = category_id.to_i if category_id
|
|
||||||
|
|
||||||
topic_allowed_users = params[:topic_allowed_users] || false
|
topic_allowed_users = params[:topic_allowed_users] || false
|
||||||
|
|
||||||
|
@ -3103,6 +3103,15 @@ describe UsersController do
|
|||||||
expect(json["users"].map { |u| u["username"] }).to include(privileged_user.username)
|
expect(json["users"].map { |u| u["username"] }).to include(privileged_user.username)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "interprets blank category id correctly" do
|
||||||
|
pm_topic = Fabricate(:private_message_post).topic
|
||||||
|
sign_in(pm_topic.user)
|
||||||
|
get "/u/search/users.json", params: {
|
||||||
|
term: "", topic_id: pm_topic.id, category_id: ""
|
||||||
|
}
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
end
|
||||||
|
|
||||||
context "when `enable_names` is true" do
|
context "when `enable_names` is true" do
|
||||||
before do
|
before do
|
||||||
SiteSetting.enable_names = true
|
SiteSetting.enable_names = true
|
||||||
|
Reference in New Issue
Block a user