diff --git a/app/serializers/site_serializer.rb b/app/serializers/site_serializer.rb index 4b89c974c0e..0ddc329fd8e 100644 --- a/app/serializers/site_serializer.rb +++ b/app/serializers/site_serializer.rb @@ -248,7 +248,7 @@ class SiteSerializer < ApplicationSerializer end def whispers_allowed_groups_names - SiteSetting.whispers_allowed_groups_map&.map { |id| Group.where(id: id).pluck_first(:name) } + Group.where(id: SiteSetting.whispers_allowed_groups_map).pluck(:name) end def include_whispers_allowed_groups_names? diff --git a/spec/serializers/site_serializer_spec.rb b/spec/serializers/site_serializer_spec.rb index 7692cccae62..e65b18c98c8 100644 --- a/spec/serializers/site_serializer_spec.rb +++ b/spec/serializers/site_serializer_spec.rb @@ -255,7 +255,7 @@ RSpec.describe SiteSerializer do SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}|#{Group::AUTO_GROUPS[:trust_level_4]}" serialized = described_class.new(Site.new(admin_guardian), scope: admin_guardian, root: false).as_json - expect(serialized[:whispers_allowed_groups_names]).to eq(["staff", "trust_level_4"]) + expect(serialized[:whispers_allowed_groups_names]).to contain_exactly("trust_level_4", "staff") end it "returns group names when user is allowed to whisper" do