fixes #101: comment limitations

This commit is contained in:
albert
2011-10-03 18:54:01 -04:00
parent 36b18a8ceb
commit f587724476
3 changed files with 9 additions and 3 deletions

View File

@@ -28,7 +28,12 @@ class Comment < ActiveRecord::Base
end
def validate_creator_is_not_limited
creator.is_privileged? || Comment.where("creator_id = ? AND created_at >= ?", creator_id, 1.hour.ago).count < 5
if creator.can_comment?
true
else
errors.add(:creator, "can not post comments within 1 week of sign up, and can only post #{Danbooru.config.member_comment_limit} comments per hour after that")
false
end
end
def update_last_commented_at

View File

@@ -282,7 +282,7 @@ class User < ActiveRecord::Base
def can_upload?
if is_contributor?
true
elsif created_at > 1.second.ago
elsif false && created_at > 1.week.ago
false
else
upload_limit > 0
@@ -292,7 +292,7 @@ class User < ActiveRecord::Base
def can_comment?
if is_privileged?
true
elsif created_at > 1.week.ago
elsif false && created_at > 1.week.ago
false
else
Comment.where("creator_id = ? and created_at > ?", id, 1.hour.ago).count < Danbooru.config.member_comment_limit

View File

@@ -7,6 +7,7 @@ class CommentTest < ActiveSupport::TestCase
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Danbooru.config.stubs(:member_comment_limit).returns(100)
end
teardown do