mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 07:48:02 +08: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
@ -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
|
||||
|
Reference in New Issue
Block a user