Staff and TL2 up are immune to newuser checks and not considered new users

This commit is contained in:
Sam 2015-03-26 16:04:32 +11:00
parent 133e3bab7a
commit 9834d11503
2 changed files with 24 additions and 1 deletions

View file

@ -312,7 +312,9 @@ class User < ActiveRecord::Base
end end
def new_user? def new_user?
created_at >= 24.hours.ago || trust_level == TrustLevel[0] (created_at >= 24.hours.ago || trust_level == TrustLevel[0]) &&
trust_level < TrustLevel[2] &&
!staff?
end end
def seen_before? def seen_before?

View file

@ -1180,4 +1180,25 @@ describe User do
end end
describe "new_user?" do
it "correctly detects new user" do
user = User.new(created_at: Time.now, trust_level: TrustLevel[0])
expect(user.new_user?).to eq(true)
user.trust_level = TrustLevel[1]
expect(user.new_user?).to eq(true)
user.trust_level = TrustLevel[2]
expect(user.new_user?).to eq(false)
user.trust_level = TrustLevel[0]
user.moderator = true
expect(user.new_user?).to eq(false)
end
end
end end