mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FIX: Remove groups when promotion is recalculated. (#31058)
The group has `grant_trust_level` setting which automatically updates the trust level when the user is added to the group. Similarly, when the user is removed from the group, the trust level is recalculated. There was a bug that when the trust level was downgraded, the user was not removed from automatic groups like for example `trust_level_3`.
This commit is contained in:

committed by
GitHub

parent
7a0762771e
commit
d75a0b1165
@ -298,10 +298,16 @@ RSpec.describe GroupUser do
|
||||
|
||||
group_user = Fabricate(:group_user, group: group, user: user)
|
||||
expect(user.reload.trust_level).to eq(4)
|
||||
expect(user.groups.where(automatic: true).map(&:name)).to eq(
|
||||
%w[trust_level_0 trust_level_1 trust_level_2 trust_level_3 trust_level_4],
|
||||
)
|
||||
|
||||
group_user.destroy!
|
||||
# keep in mind that we do not restore tl3, cause reqs can be lost
|
||||
expect(user.reload.trust_level).to eq(2)
|
||||
expect(user.groups.where(automatic: true).map(&:name)).to eq(
|
||||
%w[trust_level_0 trust_level_1 trust_level_2],
|
||||
)
|
||||
end
|
||||
|
||||
it "protects user trust level if all requirements are met" do
|
||||
|
Reference in New Issue
Block a user