diff --git a/app/serializers/category_serializer.rb b/app/serializers/category_serializer.rb index 856ecf44ee6..7ff76772d4c 100644 --- a/app/serializers/category_serializer.rb +++ b/app/serializers/category_serializer.rb @@ -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, diff --git a/spec/serializers/category_serializer_spec.rb b/spec/serializers/category_serializer_spec.rb index 3ee594228c0..b2cca6993a1 100644 --- a/spec/serializers/category_serializer_spec.rb +++ b/spec/serializers/category_serializer_spec.rb @@ -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