FIX: Destroying a user failed when it had title
...because updating the user caused a validation of the primary email and the UserEmail records are already deleted at that time.
This commit is contained in:
parent
058bf56b4c
commit
13d5ccedf5
|
@ -38,7 +38,7 @@ class GroupUser < ActiveRecord::Base
|
|||
|
||||
def grant_other_available_title
|
||||
if group.title.present? && group.title == user.title
|
||||
user.update!(title: user.next_best_title)
|
||||
user.update_attribute(:title, user.next_best_title)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -502,6 +502,14 @@ describe Group do
|
|||
expect(user.title).to eq('Different')
|
||||
expect(user.primary_group).to eq(primary_group)
|
||||
end
|
||||
|
||||
it "doesn't fail when the user gets destroyed" do
|
||||
group.update(title: 'Awesome')
|
||||
group.add(user)
|
||||
user.reload
|
||||
|
||||
UserDestroyer.new(Discourse.system_user).destroy(user)
|
||||
end
|
||||
end
|
||||
|
||||
it "has custom fields" do
|
||||
|
|
Loading…
Reference in New Issue