diff --git a/app/models/group.rb b/app/models/group.rb index 5cab53bdc4e..93ff94b7a07 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -690,7 +690,7 @@ class Group < ActiveRecord::Base has_webhooks = WebHook.active_web_hooks(:group_user) payload = WebHook.generate_payload(:group_user, group_user, WebHookGroupUserSerializer) if has_webhooks group_user.destroy - user.update_columns(primary_group_id: nil) if user.primary_group_id == self.id + user.update_attribute(:primary_group_id, nil) if user.primary_group_id == self.id DiscourseEvent.trigger(:user_removed_from_group, user, self) WebHook.enqueue_hooks(:group_user, :user_removed_from_group, id: group_user.id, diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 2cd66c8ee93..5f989c0cb0a 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -315,7 +315,7 @@ describe Group do end it "Correctly handles removal of primary group" do - group = Fabricate(:group) + group = Fabricate(:group, flair_icon: "icon") user = Fabricate(:user) group.add(user) group.save @@ -330,6 +330,7 @@ describe Group do user.reload expect(user.primary_group).to eq nil + expect(user.flair_group_id).to eq nil end it "Can update moderator/staff/admin groups correctly" do