mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
Feature: unconditionally consider TL0 users as "first day" users
This commit is contained in:
@ -537,7 +537,7 @@ class User < ActiveRecord::Base
|
|||||||
def new_user_posting_on_first_day?
|
def new_user_posting_on_first_day?
|
||||||
!staff? &&
|
!staff? &&
|
||||||
trust_level < TrustLevel[2] &&
|
trust_level < TrustLevel[2] &&
|
||||||
(self.first_post_created_at.nil? || self.first_post_created_at >= 24.hours.ago)
|
(trust_level == TrustLevel[0] || self.first_post_created_at.nil? || self.first_post_created_at >= 24.hours.ago)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_user?
|
def new_user?
|
||||||
|
@ -990,6 +990,12 @@ describe User do
|
|||||||
u.user_stat.first_post_created_at = 25.hours.ago
|
u.user_stat.first_post_created_at = 25.hours.ago
|
||||||
expect(u.new_user_posting_on_first_day?).to eq(false)
|
expect(u.new_user_posting_on_first_day?).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "considers trust level 0 users as new users unconditionally" do
|
||||||
|
u = Fabricate(:user, created_at: 28.hours.ago, trust_level: TrustLevel[0])
|
||||||
|
u.user_stat.first_post_created_at = 25.hours.ago
|
||||||
|
expect(u.new_user_posting_on_first_day?).to eq(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'api keys' do
|
describe 'api keys' do
|
||||||
|
Reference in New Issue
Block a user