FIX: Let user clear their flair group (#13669)
Users were able to select their flair, but were not able to clear it by selecting (none).
This commit is contained in:
parent
ba62ecac68
commit
43d4859d30
|
@ -123,7 +123,8 @@ class UserUpdater
|
|||
|
||||
if attributes[:flair_group_id] &&
|
||||
attributes[:flair_group_id] != user.flair_group_id &&
|
||||
guardian.can_use_primary_group?(user, attributes[:flair_group_id])
|
||||
(attributes[:flair_group_id].blank? ||
|
||||
guardian.can_use_primary_group?(user, attributes[:flair_group_id]))
|
||||
|
||||
user.flair_group_id = attributes[:flair_group_id]
|
||||
end
|
||||
|
|
|
@ -370,6 +370,21 @@ describe UserUpdater do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when updating flair group' do
|
||||
let(:group) { Fabricate(:group, name: "Group", flair_bg_color: "#111111", flair_color: "#999999", flair_icon: "icon") }
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
it 'updates when setting is enabled' do
|
||||
group.add(user)
|
||||
|
||||
UserUpdater.new(acting_user, user).update(flair_group_id: group.id)
|
||||
expect(user.reload.flair_group_id).to eq(group.id)
|
||||
|
||||
UserUpdater.new(acting_user, user).update(flair_group_id: "")
|
||||
expect(user.reload.flair_group_id).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when update fails' do
|
||||
it 'returns false' do
|
||||
user = Fabricate(:user)
|
||||
|
|
Loading…
Reference in New Issue