FIX: setting tl3_min_likes_received too high can make it impossible to be promoted to tl3. Cap the min number of days over which those likes must be received.
This commit is contained in:
parent
cee4da82d8
commit
c3e81dba68
|
@ -174,7 +174,9 @@ class TrustLevel3Requirements
|
|||
end
|
||||
|
||||
def min_likes_received_days
|
||||
(min_likes_received.to_f / 3.0).ceil
|
||||
# Since min_likes_received / 3 can be greater than the number of days in time_period,
|
||||
# cap this result to be less than time_period.
|
||||
[(min_likes_received.to_f / 3.0).ceil, (0.75 * time_period.to_f).ceil].min
|
||||
end
|
||||
|
||||
def num_likes_received_users
|
||||
|
|
|
@ -67,6 +67,20 @@ describe TrustLevel3Requirements do
|
|||
expect(tl3_requirements.min_likes_received_days).to eq(7)
|
||||
expect(tl3_requirements.min_likes_received_users).to eq(5)
|
||||
end
|
||||
|
||||
it "min_likes_received_days is capped" do
|
||||
SiteSetting.tl3_requires_likes_received = 600
|
||||
expect(tl3_requirements.min_likes_received).to eq(600)
|
||||
expect(tl3_requirements.min_likes_received_days).to eq(75) # 0.75 * tl3_time_period
|
||||
end
|
||||
|
||||
it "min_likes_received_days works when time_period is 1" do
|
||||
SiteSetting.tl3_requires_likes_received = 20
|
||||
SiteSetting.tl3_time_period = 1
|
||||
expect(tl3_requirements.min_likes_received).to eq(20)
|
||||
expect(tl3_requirements.min_likes_received_days).to eq(1)
|
||||
expect(tl3_requirements.min_likes_received_users).to eq(5)
|
||||
end
|
||||
end
|
||||
|
||||
describe "days_visited" do
|
||||
|
|
Loading…
Reference in New Issue