users: remove user is not ip banned validation.
This is handled on the controller level now.
This commit is contained in:
@@ -76,7 +76,6 @@ class User < ApplicationRecord
|
||||
validates_inclusion_of :per_page, in: (1..PostSets::Post::MAX_PER_PAGE)
|
||||
validates_confirmation_of :password
|
||||
validates_presence_of :comment_threshold
|
||||
validate :validate_ip_addr_is_not_banned, :on => :create
|
||||
validate :validate_sock_puppets, :on => :create, :if => -> { Danbooru.config.enable_sock_puppet_validation? }
|
||||
before_validation :normalize_blacklisted_tags
|
||||
before_validation :set_per_page
|
||||
@@ -132,12 +131,6 @@ class User < ApplicationRecord
|
||||
scope :admins, -> { where(level: Levels::ADMIN) }
|
||||
|
||||
module BanMethods
|
||||
def validate_ip_addr_is_not_banned
|
||||
if IpBan.is_banned?(CurrentUser.ip_addr)
|
||||
errors[:base] << "IP address is banned"
|
||||
end
|
||||
end
|
||||
|
||||
def unban!
|
||||
self.is_banned = false
|
||||
save
|
||||
|
||||
@@ -39,15 +39,6 @@ class UserTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
should "not validate if the originating ip address is banned" do
|
||||
CurrentUser.scoped(User.anonymous, "1.2.3.4") do
|
||||
create(:ip_ban, ip_addr: '1.2.3.4')
|
||||
user = build(:user, last_ip_addr: '1.2.3.4')
|
||||
refute(user.valid?)
|
||||
assert_equal("IP address is banned", user.errors.full_messages.join)
|
||||
end
|
||||
end
|
||||
|
||||
should "limit comment votes" do
|
||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||
Danbooru.config.stubs(:member_comment_limit).returns(10)
|
||||
|
||||
Reference in New Issue
Block a user