FIX: update flair group of all members if primary group setting changed. (#14762)

Previously, if we enable the `primary_group` setting on a group then the `flair_group_id` of its' members are not affected.
This commit is contained in:
Vinoth Kannan
2021-10-28 22:56:44 +05:30
committed by GitHub
parent c62242c6b3
commit deee715a2c
2 changed files with 26 additions and 16 deletions

View File

@ -198,12 +198,19 @@ describe Group do
end
describe '#primary_group=' do
it "updates all members' #primary_group" do
before do
group.add(user)
end
it "updates all members' #primary_group" do
expect { group.update(primary_group: true) }.to change { user.reload.primary_group }.from(nil).to(group)
expect { group.update(primary_group: false) }.to change { user.reload.primary_group }.from(group).to(nil)
end
it "updates all members' #flair_group" do
expect { group.update(primary_group: true) }.to change { user.reload.flair_group }.from(nil).to(group)
expect { group.update(primary_group: false) }.to change { user.reload.flair_group }.from(group).to(nil)
end
end
describe '#title=' do