mirror of
https://github.com/discourse/discourse.git
synced 2024-12-04 03:33:44 +08:00
FIX: Serialize permissions for everyone group
The permissions for the 'everyone' group were not serialized because
the list of groups a user can view did not include it. This bug was
introduced in commit dfaf9831f7
.
This commit is contained in:
parent
f0574564c4
commit
dcbd788412
|
@ -37,7 +37,7 @@ class CategorySerializer < SiteCategorySerializer
|
|||
.category_groups
|
||||
.joins(:group)
|
||||
.includes(:group)
|
||||
.merge(Group.visible_groups(scope&.user, "groups.name ASC"))
|
||||
.merge(Group.visible_groups(scope&.user, "groups.name ASC", include_everyone: true))
|
||||
.map do |cg|
|
||||
{
|
||||
permission_type: cg.permission_type,
|
||||
|
|
|
@ -100,7 +100,19 @@ describe CategorySerializer do
|
|||
expect(json[:group_permissions]).to eq([
|
||||
{ permission_type: CategoryGroup.permission_types[:readonly], group_name: group.name },
|
||||
{ permission_type: CategoryGroup.permission_types[:full], group_name: private_group.name },
|
||||
{ permission_type: CategoryGroup.permission_types[:full], group_name: user_group.name }
|
||||
{ permission_type: CategoryGroup.permission_types[:full], group_name: user_group.name },
|
||||
{ permission_type: CategoryGroup.permission_types[:readonly], group_name: 'everyone' },
|
||||
])
|
||||
end
|
||||
|
||||
it "returns the group permissions for everyone group too" do
|
||||
category.set_permissions(everyone: :readonly)
|
||||
category.save!
|
||||
|
||||
json = described_class.new(category, scope: Guardian.new(admin), root: false).as_json
|
||||
|
||||
expect(json[:group_permissions]).to eq([
|
||||
{ permission_type: CategoryGroup.permission_types[:readonly], group_name: 'everyone' },
|
||||
])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user