mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
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
|
def grant_other_available_title
|
||||||
if group.title.present? && group.title == user.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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -502,6 +502,14 @@ describe Group do
|
|||||||
expect(user.title).to eq('Different')
|
expect(user.title).to eq('Different')
|
||||||
expect(user.primary_group).to eq(primary_group)
|
expect(user.primary_group).to eq(primary_group)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
it "has custom fields" do
|
it "has custom fields" do
|
||||||
|
Loading…
Reference in New Issue
Block a user