mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 11:59:17 -05:00
Staff and TL2 up are immune to newuser checks and not considered new users
This commit is contained in:
parent
133e3bab7a
commit
9834d11503
2 changed files with 24 additions and 1 deletions
|
@ -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?
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue