diff --git a/app/models/group_user.rb b/app/models/group_user.rb index 664a333e9bd..7b8d8652a61 100644 --- a/app/models/group_user.rb +++ b/app/models/group_user.rb @@ -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 diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 0cb8362c804..ddc3224e331 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -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