mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: max topics/replies per day for new users now starts counting from the first post, not signup date
This commit is contained in:
@ -806,17 +806,29 @@ describe User do
|
||||
|
||||
end
|
||||
|
||||
describe "#first_day_user?" do
|
||||
describe "#new_user_posting_on_first_day?" do
|
||||
|
||||
def test_user?(opts={})
|
||||
Fabricate.build(:user, {created_at: Time.now}.merge(opts)).first_day_user?
|
||||
Fabricate.build(:user, {created_at: Time.zone.now}.merge(opts)).new_user_posting_on_first_day?
|
||||
end
|
||||
|
||||
it "works" do
|
||||
it "handles when user has never posted" do
|
||||
expect(test_user?).to eq(true)
|
||||
expect(test_user?(moderator: true)).to eq(false)
|
||||
expect(test_user?(trust_level: TrustLevel[2])).to eq(false)
|
||||
expect(test_user?(created_at: 2.days.ago)).to eq(false)
|
||||
expect(test_user?(created_at: 2.days.ago)).to eq(true)
|
||||
end
|
||||
|
||||
it "is true for a user who posted less than 24 hours ago but was created over 1 day ago" do
|
||||
u = Fabricate(:user, created_at: 28.hours.ago)
|
||||
u.user_stat.first_post_created_at = 1.hour.ago
|
||||
expect(u.new_user_posting_on_first_day?).to eq(true)
|
||||
end
|
||||
|
||||
it "is false if first post was more than 24 hours ago" do
|
||||
u = Fabricate(:user, created_at: 28.hours.ago)
|
||||
u.user_stat.first_post_created_at = 25.hours.ago
|
||||
expect(u.new_user_posting_on_first_day?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user