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
499793cbbc
commit
07d8189edd
|
@ -37,7 +37,7 @@ class CategorySerializer < SiteCategorySerializer
|
||||||
.category_groups
|
.category_groups
|
||||||
.joins(:group)
|
.joins(:group)
|
||||||
.includes(: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|
|
.map do |cg|
|
||||||
{
|
{
|
||||||
permission_type: cg.permission_type,
|
permission_type: cg.permission_type,
|
||||||
|
|
|
@ -98,7 +98,19 @@ describe CategorySerializer do
|
||||||
expect(json[:group_permissions]).to eq([
|
expect(json[:group_permissions]).to eq([
|
||||||
{ permission_type: CategoryGroup.permission_types[:readonly], group_name: group.name },
|
{ 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: 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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue