mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 20:33:41 +08:00
FIX: Group name was being reverted to non-localized version.
https://meta.discourse.org/t/localized-staff-group-names-changed/65360/16
This commit is contained in:
parent
3982a8ef30
commit
5f0351348b
|
@ -205,11 +205,8 @@ class Group < ActiveRecord::Base
|
||||||
localized_name = I18n.t("groups.default_names.#{name}").downcase
|
localized_name = I18n.t("groups.default_names.#{name}").downcase
|
||||||
validator = UsernameValidator.new(localized_name)
|
validator = UsernameValidator.new(localized_name)
|
||||||
|
|
||||||
group.name =
|
|
||||||
if !Group.where("LOWER(name) = ?", localized_name).exists? && validator.valid_format?
|
if !Group.where("LOWER(name) = ?", localized_name).exists? && validator.valid_format?
|
||||||
localized_name
|
group.name = localized_name
|
||||||
else
|
|
||||||
name
|
|
||||||
end
|
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
|
||||||
|
|
|
@ -162,6 +162,28 @@ describe Group do
|
||||||
expect(g.visible).to eq(false)
|
expect(g.visible).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not reset the localized name" do
|
||||||
|
begin
|
||||||
|
default_locale = SiteSetting.default_locale
|
||||||
|
I18n.locale = SiteSetting.default_locale = 'fi'
|
||||||
|
|
||||||
|
group = Group.find(Group::AUTO_GROUPS[:everyone])
|
||||||
|
group.update!(name: I18n.t("groups.default_names.everyone"))
|
||||||
|
|
||||||
|
Group.refresh_automatic_group!(:everyone)
|
||||||
|
|
||||||
|
expect(group.reload.name).to eq(I18n.t("groups.default_names.everyone"))
|
||||||
|
|
||||||
|
I18n.locale = SiteSetting.default_locale = 'en'
|
||||||
|
|
||||||
|
Group.refresh_automatic_group!(:everyone)
|
||||||
|
|
||||||
|
expect(group.reload.name).to eq(I18n.t("groups.default_names.everyone"))
|
||||||
|
ensure
|
||||||
|
I18n.locale = SiteSetting.default_locale = default_locale
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "uses the localized name if name has not been taken" do
|
it "uses the localized name if name has not been taken" do
|
||||||
begin
|
begin
|
||||||
default_locale = SiteSetting.default_locale
|
default_locale = SiteSetting.default_locale
|
||||||
|
|
Loading…
Reference in New Issue
Block a user