FIX: ensure GroupChooser works with localized group names (#30593)

The "Tag Groups Form" component was using group names to handle
permissions. This works just fine when the default locale is "English"
but breaks as soon as it's changed to a different locale.

The fix is to use the group id's for handling the permissions instead of
the group name.

Reported in https://meta.discourse.org/t/221849
This commit is contained in:
Régis Hanol
2025-01-13 11:29:04 +01:00
committed by GitHub
parent 79b68bc32b
commit 03119312b5
9 changed files with 65 additions and 142 deletions

View File

@@ -13,7 +13,7 @@ RSpec.describe TagGroupSerializer do
serialized = TagGroupSerializer.new(tag_group, root: false).as_json
expect(serialized[:permissions].keys).to contain_exactly("staff")
expect(serialized[:permissions].keys).to contain_exactly(Group::AUTO_GROUPS[:staff])
end
it "doesn't return tag synonyms" do
@@ -21,6 +21,6 @@ RSpec.describe TagGroupSerializer do
synonym = Fabricate(:tag, target_tag: tag)
tag_group = Fabricate(:tag_group, tags: [tag, synonym])
serialized = TagGroupSerializer.new(tag_group, root: false).as_json
expect(serialized[:tag_names]).to eq([tag.name])
expect(serialized[:tag_names]).to contain_exactly(tag.name)
end
end