FIX: always allow tl1 through for typing speed tests

This commit is contained in:
Sam 2015-08-06 10:07:07 +10:00
parent dbd6099b89
commit 11d39345b3
2 changed files with 34 additions and 6 deletions

View File

@ -32,15 +32,19 @@ class NewPostManager
user = manager.user
args = manager.args
args[:first_post_checks] &&
user.post_count == 0
!!(
args[:first_post_checks] &&
user.post_count == 0
)
end
def self.is_fast_typer?(manager)
args = manager.args
is_first_post?(manager) &&
args[:typing_duration_msecs].to_i < SiteSetting.min_first_post_typing_time
args[:typing_duration_msecs].to_i < SiteSetting.min_first_post_typing_time &&
SiteSetting.auto_block_fast_typers_on_first_post &&
manager.user.trust_level <= SiteSetting.auto_block_fast_typers_max_trust_level
end
def self.matches_auto_block_regex?(manager)
@ -78,9 +82,7 @@ class NewPostManager
result = manager.enqueue('default')
block = is_fast_typer?(manager) &&
SiteSetting.auto_block_fast_typers_on_first_post &&
SiteSetting.auto_block_fast_typers_max_trust_level <= manager.user.trust_level
block = is_fast_typer?(manager)
block ||= matches_auto_block_regex?(manager)

View File

@ -192,4 +192,30 @@ describe NewPostManager do
end
context "user needs approval?" do
let :user do
user = Fabricate.build(:user, trust_level: 0)
user_stat = UserStat.new(post_count: 0)
user.user_stat = user_stat
user
end
it "handles user_needs_approval? correctly" do
u = user
default = NewPostManager.new(u,{})
expect(NewPostManager.user_needs_approval?(default)).to eq(false)
with_check = NewPostManager.new(u,{first_post_checks: true})
expect(NewPostManager.user_needs_approval?(with_check)).to eq(true)
u.trust_level = 1
with_check_tl1 = NewPostManager.new(u,{first_post_checks: true})
expect(NewPostManager.user_needs_approval?(with_check_tl1)).to eq(false)
end
end
end