mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
FIX: show primary user group options to members in account prefs (#27664)
The user serializer groups method previously relied on the members_visible_groups to determine groups that the user should be able to see, however this setting was intended for visibility of group members (which is entirely different). The result of this could be seen when choosing a primary group from user preferences -> account, due to the serializer the group name was not visible when members_visible_groups was set to owners.
This commit is contained in:
parent
4f87f0d7ef
commit
640dccd224
@ -90,7 +90,7 @@ class UserSerializer < UserCardSerializer
|
||||
end
|
||||
|
||||
def groups
|
||||
object.groups.order(:id).visible_groups(scope.user).members_visible_groups(scope.user)
|
||||
object.groups.order(:id).visible_groups(scope.user)
|
||||
end
|
||||
|
||||
def group_users
|
||||
|
@ -495,4 +495,26 @@ RSpec.describe UserSerializer do
|
||||
expect(serializer.as_json[:display_sidebar_tags]).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context "with groups" do
|
||||
fab!(:group) do
|
||||
Fabricate(
|
||||
:group,
|
||||
visibility_level: Group.visibility_levels[:public],
|
||||
members_visibility_level: Group.visibility_levels[:owners],
|
||||
)
|
||||
end
|
||||
let(:serializer) { UserSerializer.new(user, scope: Guardian.new, root: false) }
|
||||
|
||||
before do
|
||||
group.add(user)
|
||||
group.save!
|
||||
end
|
||||
|
||||
it "should show group even when members list is not visible" do
|
||||
json = serializer.as_json
|
||||
expect(json[:groups].length).to eq(1)
|
||||
expect(json[:groups].first[:id]).to eq(group.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user