comments: remove 10 comment votes per hour limit.

This commit is contained in:
evazion
2020-03-21 22:29:55 -05:00
parent 63f7311489
commit 88a8f459ed
3 changed files with 0 additions and 22 deletions

View File

@@ -5,7 +5,6 @@ class CommentVote < ApplicationRecord
belongs_to :user
validates_presence_of :score
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "have already voted for this comment"
validate :validate_user_can_vote
validate :validate_comment_can_be_down_voted
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
@@ -31,12 +30,6 @@ class CommentVote < ApplicationRecord
q.apply_default_order(params)
end
def validate_user_can_vote
if !user.can_comment_vote?
errors.add :base, "You cannot vote on more than 10 comments per hour"
end
end
def validate_comment_can_be_down_voted
if is_positive? && comment.creator == CurrentUser.user
errors.add :base, "You cannot upvote your own comments"

View File

@@ -402,10 +402,6 @@ class User < ApplicationRecord
end
end
def can_comment_vote?
CommentVote.where("user_id = ? and created_at > ?", id, 1.hour.ago).count < 10
end
def upload_limit
@upload_limit ||= UploadLimit.new(self)
end

View File

@@ -39,17 +39,6 @@ class UserTest < ActiveSupport::TestCase
end
end
should "limit comment votes" do
Danbooru.config.stubs(:member_comment_limit).returns(10)
assert(@user.can_comment_vote?)
create_list(:comment_vote, 10, user: @user, score: -1)
assert(!@user.can_comment_vote?)
CommentVote.update_all("created_at = '1990-01-01'")
assert(@user.can_comment_vote?)
end
should "authenticate" do
assert(User.authenticate(@user.name, "password"), "Authentication should have succeeded")
assert(!User.authenticate(@user.name, "password2"), "Authentication should not have succeeded")