From 88a8f459ed7e36280d27e91fff7f4396c989272b Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 21 Mar 2020 22:29:55 -0500 Subject: [PATCH] comments: remove 10 comment votes per hour limit. --- app/models/comment_vote.rb | 7 ------- app/models/user.rb | 4 ---- test/unit/user_test.rb | 11 ----------- 3 files changed, 22 deletions(-) diff --git a/app/models/comment_vote.rb b/app/models/comment_vote.rb index 9d080aa54..d3eb2101c 100644 --- a/app/models/comment_vote.rb +++ b/app/models/comment_vote.rb @@ -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" diff --git a/app/models/user.rb b/app/models/user.rb index 45b985e5b..ca2f90a74 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 6da35b4d2..68210932b 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -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")