mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:22 +08:00
Allow users with group_locked_trust_level to be promoted to tl3 (#6249)
This commit is contained in:
parent
0d5ebcb21d
commit
3cd4dc0f5f
|
@ -8,9 +8,8 @@ module Jobs
|
|||
demoted_user_ids = []
|
||||
User.real.where(
|
||||
trust_level: TrustLevel[3],
|
||||
manual_locked_trust_level: nil,
|
||||
group_locked_trust_level: nil
|
||||
).find_each do |u|
|
||||
manual_locked_trust_level: nil
|
||||
).where("group_locked_trust_level IS NULL OR group_locked_trust_level < ?", TrustLevel[3]).find_each do |u|
|
||||
# Don't demote too soon after being promoted
|
||||
next if u.on_tl3_grace_period?
|
||||
|
||||
|
@ -23,8 +22,7 @@ module Jobs
|
|||
# Promotions
|
||||
User.real.not_suspended.where(
|
||||
trust_level: TrustLevel[2],
|
||||
manual_locked_trust_level: nil,
|
||||
group_locked_trust_level: nil
|
||||
manual_locked_trust_level: nil
|
||||
).where.not(id: demoted_user_ids)
|
||||
.joins(:user_stat)
|
||||
.where("user_stats.days_visited >= ?", SiteSetting.tl3_requires_days_visited)
|
||||
|
|
|
@ -24,6 +24,14 @@ describe Jobs::Tl3Promotions do
|
|||
run_job
|
||||
end
|
||||
|
||||
it "promotes a qualifying tl2 user who has a group_locked_trust_level" do
|
||||
_group_locked_user = Fabricate(:user, trust_level: TrustLevel[2], group_locked_trust_level: TrustLevel[1])
|
||||
create_qualifying_stats(_group_locked_user)
|
||||
TrustLevel3Requirements.any_instance.stubs(:requirements_met?).returns(true)
|
||||
Promotion.any_instance.expects(:change_trust_level!).with(TrustLevel[3], anything).once
|
||||
run_job
|
||||
end
|
||||
|
||||
it "doesn't promote tl1 and tl0 users who have met tl3 requirements" do
|
||||
_tl1_user = Fabricate(:user, trust_level: TrustLevel[1])
|
||||
_tl0_user = Fabricate(:user, trust_level: TrustLevel[0])
|
||||
|
@ -83,5 +91,27 @@ describe Jobs::Tl3Promotions do
|
|||
expect(user.reload.trust_level).to eq(TrustLevel[3])
|
||||
end
|
||||
|
||||
it "demotes a user with a group_locked_trust_level of 2" do
|
||||
user = nil
|
||||
freeze_time(4.days.ago) do
|
||||
user = Fabricate(:user, trust_level: TrustLevel[3], group_locked_trust_level: TrustLevel[2])
|
||||
end
|
||||
TrustLevel3Requirements.any_instance.stubs(:requirements_met?).returns(false)
|
||||
TrustLevel3Requirements.any_instance.stubs(:requirements_lost?).returns(true)
|
||||
run_job
|
||||
expect(user.reload.trust_level).to eq(TrustLevel[2])
|
||||
|
||||
end
|
||||
|
||||
it "doesn't demote user if their group_locked_trust_level is 3" do
|
||||
user = nil
|
||||
freeze_time(4.days.ago) do
|
||||
user = Fabricate(:user, trust_level: TrustLevel[3], group_locked_trust_level: TrustLevel[3])
|
||||
end
|
||||
TrustLevel3Requirements.any_instance.stubs(:requirements_met?).returns(false)
|
||||
TrustLevel3Requirements.any_instance.stubs(:requirements_lost?).returns(true)
|
||||
run_job
|
||||
expect(user.reload.trust_level).to eq(TrustLevel[3])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user