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

@ -2378,6 +2378,39 @@ describe Guardian do
end
end
describe 'can_use_primary_group?' do
fab!(:group) { Fabricate(:group, title: 'Groupie') }
it 'is false without a logged in user' do
expect(Guardian.new(nil).can_use_primary_group?(user)).to be_falsey
end
it 'is false with no group_id' do
user.update(groups: [group])
expect(Guardian.new(user).can_use_primary_group?(user, nil)).to be_falsey
end
it 'is false if the group does not exist' do
user.update(groups: [group])
expect(Guardian.new(user).can_use_primary_group?(user, Group.last.id + 1)).to be_falsey
end
it 'is false if the user is not a part of the group' do
user.update(groups: [])
expect(Guardian.new(user).can_use_primary_group?(user, group.id)).to be_falsey
end
it 'is false if the group is automatic' do
user.update(groups: [Group.new(name: 'autooo', automatic: true)])
expect(Guardian.new(user).can_use_primary_group?(user, group.id)).to be_falsey
end
it 'is true if the user is a part of the group, and the group is custom' do
user.update(groups: [group])
expect(Guardian.new(user).can_use_primary_group?(user, group.id)).to be_truthy
end
end
describe 'can_change_trust_level?' do
it 'is false without a logged in user' do