comments: remove 10 comment votes per hour limit.
This commit is contained in:
@@ -5,7 +5,6 @@ class CommentVote < ApplicationRecord
|
|||||||
belongs_to :user
|
belongs_to :user
|
||||||
validates_presence_of :score
|
validates_presence_of :score
|
||||||
validates_uniqueness_of :user_id, :scope => :comment_id, :message => "have already voted for this comment"
|
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
|
validate :validate_comment_can_be_down_voted
|
||||||
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
|
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)
|
q.apply_default_order(params)
|
||||||
end
|
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
|
def validate_comment_can_be_down_voted
|
||||||
if is_positive? && comment.creator == CurrentUser.user
|
if is_positive? && comment.creator == CurrentUser.user
|
||||||
errors.add :base, "You cannot upvote your own comments"
|
errors.add :base, "You cannot upvote your own comments"
|
||||||
|
|||||||
@@ -402,10 +402,6 @@ class User < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_comment_vote?
|
|
||||||
CommentVote.where("user_id = ? and created_at > ?", id, 1.hour.ago).count < 10
|
|
||||||
end
|
|
||||||
|
|
||||||
def upload_limit
|
def upload_limit
|
||||||
@upload_limit ||= UploadLimit.new(self)
|
@upload_limit ||= UploadLimit.new(self)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,17 +39,6 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
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
|
should "authenticate" do
|
||||||
assert(User.authenticate(@user.name, "password"), "Authentication should have succeeded")
|
assert(User.authenticate(@user.name, "password"), "Authentication should have succeeded")
|
||||||
assert(!User.authenticate(@user.name, "password2"), "Authentication should not have succeeded")
|
assert(!User.authenticate(@user.name, "password2"), "Authentication should not have succeeded")
|
||||||
|
|||||||
Reference in New Issue
Block a user