mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
FIX: ensure the group 'everyone' is never shown when using a different locale
This commit is contained in:
parent
dc0d302345
commit
81e2a0099f
@ -1,10 +1,9 @@
|
|||||||
class Admin::GroupsController < Admin::AdminController
|
class Admin::GroupsController < Admin::AdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
groups = Group.order(:name).where("name <> 'everyone'")
|
groups = Group.order(:name).where("id <> ?", Group::AUTO_GROUPS[:everyone])
|
||||||
|
|
||||||
if search = params[:search]
|
if search = params[:search].to_s
|
||||||
search = search.to_s
|
|
||||||
groups = groups.where("name ILIKE ?", "%#{search}%")
|
groups = groups.where("name ILIKE ?", "%#{search}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,13 +149,10 @@ class Group < ActiveRecord::Base
|
|||||||
group.save!
|
group.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
group.name = I18n.t("groups.default_names.#{name}")
|
|
||||||
|
|
||||||
# don't allow shoddy localization to break this
|
# don't allow shoddy localization to break this
|
||||||
validator = UsernameValidator.new(group.name)
|
localized_name = I18n.t("groups.default_names.#{name}")
|
||||||
unless validator.valid_format?
|
validator = UsernameValidator.new(localized_name)
|
||||||
group.name = name
|
group.name = validator.valid_format? ? localized_name : name
|
||||||
end
|
|
||||||
|
|
||||||
# the everyone group is special, it can include non-users so there is no
|
# the everyone group is special, it can include non-users so there is no
|
||||||
# way to have the membership in a table
|
# way to have the membership in a table
|
||||||
|
@ -19,7 +19,9 @@ describe Admin::GroupsController do
|
|||||||
|
|
||||||
xhr :get, :index
|
xhr :get, :index
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(::JSON.parse(response.body).keep_if {|r| r["id"] == group.id }).to eq([{
|
json = ::JSON.parse(response.body)
|
||||||
|
expect(json.select { |r| r["id"] == Group::AUTO_GROUPS[:everyone] }).to be_empty
|
||||||
|
expect(json.select { |r| r["id"] == group.id }).to eq([{
|
||||||
"id"=>group.id,
|
"id"=>group.id,
|
||||||
"name"=>group.name,
|
"name"=>group.name,
|
||||||
"user_count"=>1,
|
"user_count"=>1,
|
||||||
@ -135,6 +137,4 @@ describe Admin::GroupsController do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user