mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 20:27:28 +08:00
FIX: Don't raise an exception if we can't update the user on demotion
This is causing issues when purging old users, if they are set up in the exact condition where they will be demoted into another group, but also do not have a primary email.
This commit is contained in:
parent
d473ddd02c
commit
ac9577bcc7
|
@ -126,8 +126,8 @@ class Promotion
|
|||
# Then consider the group locked level
|
||||
user_group_granted_trust_level = user.group_granted_trust_level
|
||||
|
||||
unless user_group_granted_trust_level.blank?
|
||||
return user.update!(
|
||||
if user_group_granted_trust_level.present?
|
||||
return user.update(
|
||||
trust_level: user_group_granted_trust_level
|
||||
)
|
||||
end
|
||||
|
|
|
@ -390,6 +390,17 @@ describe UserDestroyer do
|
|||
d.destroy(user)
|
||||
}.to change { User.count }.by(-1)
|
||||
end
|
||||
|
||||
it 'can delete the user if they were to fall into another trust level and have no email' do
|
||||
g2 = Fabricate(:group, grant_trust_level: 1)
|
||||
g2.add(user)
|
||||
|
||||
UserEmail.where(user: user).delete_all
|
||||
user.reload
|
||||
expect {
|
||||
UserDestroyer.new(admin).destroy(user)
|
||||
}.to change { User.count }.by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'user has staff action logs' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user