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:
Mark VanLandingham
2019-10-28 12:46:27 -05:00
committed by GitHub
parent 0e1c5c6bba
commit 4eb54f08b2
14 changed files with 115 additions and 6 deletions

View File

@@ -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)