FIX: error looking at users in admin when tl3_promotion_min_duration is set to a very high value
This commit is contained in:
parent
c2add85e75
commit
12f132736b
|
@ -947,6 +947,8 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def on_tl3_grace_period?
|
||||
return true if SiteSetting.tl3_promotion_min_duration.to_i.days.ago.year < 2013
|
||||
|
||||
UserHistory.for(self, :auto_trust_level_change)
|
||||
.where('created_at >= ?', SiteSetting.tl3_promotion_min_duration.to_i.days.ago)
|
||||
.where(previous_value: TrustLevel[2].to_s)
|
||||
|
|
|
@ -1101,6 +1101,7 @@ trust:
|
|||
default: 5
|
||||
tl3_promotion_min_duration:
|
||||
default: 14
|
||||
max: 10000
|
||||
tl3_requires_likes_given:
|
||||
default: 30
|
||||
tl3_requires_likes_received:
|
||||
|
|
|
@ -113,5 +113,18 @@ describe Jobs::Tl3Promotions do
|
|||
run_job
|
||||
expect(user.reload.trust_level).to eq(TrustLevel[3])
|
||||
end
|
||||
|
||||
it "doesn't demote with very high tl3_promotion_min_duration value" do
|
||||
SiteSetting.stubs(:tl3_promotion_min_duration).returns(2000000000)
|
||||
user = nil
|
||||
freeze_time(500.days.ago) do
|
||||
user = create_leader_user
|
||||
end
|
||||
expect(user).to be_on_tl3_grace_period
|
||||
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