mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Site setting/UI to allow users to set their primary group (#8244)
* FEATURE: Site setting/ui to allow users to set their primary group * prettier and remove logic from account template * added 1 to 43 to make web_hook_user_serializer_spec pass
This commit is contained in:
committed by
GitHub
parent
0e1c5c6bba
commit
4eb54f08b2
@@ -249,6 +249,31 @@ describe UserUpdater do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when updating primary group' do
|
||||
let(:new_group) { Group.create(name: 'new_group') }
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
it 'updates when setting is enabled' do
|
||||
SiteSetting.user_selected_primary_groups = true
|
||||
user.groups << new_group
|
||||
user.update(primary_group_id: nil)
|
||||
UserUpdater.new(acting_user, user).update(primary_group_id: new_group.id)
|
||||
|
||||
user.reload
|
||||
expect(user.primary_group_id).to eq new_group.id
|
||||
end
|
||||
|
||||
it 'does not update when setting is disabled' do
|
||||
SiteSetting.user_selected_primary_groups = false
|
||||
user.groups << new_group
|
||||
user.update(primary_group_id: nil)
|
||||
UserUpdater.new(acting_user, user).update(primary_group_id: new_group.id)
|
||||
|
||||
user.reload
|
||||
expect(user.primary_group_id).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when update fails' do
|
||||
it 'returns false' do
|
||||
user = Fabricate(:user)
|
||||
|
||||
Reference in New Issue
Block a user