Autoban dmail spambots (#3408).
If a user sends spam to more than 10 users within a 24 hour window, automatically ban them for 3 days.
This commit is contained in:
@@ -3,6 +3,7 @@ require 'test_helper'
|
||||
class DmailTest < ActiveSupport::TestCase
|
||||
context "A dmail" do
|
||||
setup do
|
||||
User.any_instance.stubs(:validate_sock_puppets).returns(true)
|
||||
@user = FactoryGirl.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "1.2.3.4"
|
||||
@@ -27,6 +28,20 @@ class DmailTest < ActiveSupport::TestCase
|
||||
assert(@recipient.dmails.last.is_spam?)
|
||||
end
|
||||
end
|
||||
|
||||
should "autoban spammers after sending spam to N distinct users" do
|
||||
Dmail.any_instance.expects(:spam?).returns(true)
|
||||
|
||||
users = FactoryGirl.create_list(:user, Dmail::AUTOBAN_THRESHOLD)
|
||||
users.each do |user|
|
||||
Dmail.create_split(from: @user, to: user, title: "spam", body: "wonderful spam")
|
||||
end
|
||||
|
||||
assert_equal(true, Dmail.is_spammer?(@user))
|
||||
assert_equal(true, @user.reload.is_banned)
|
||||
assert_equal(1, @user.bans.count)
|
||||
assert_match(/Spambot./, @user.bans.last.reason)
|
||||
end
|
||||
end
|
||||
|
||||
context "filter" do
|
||||
|
||||
Reference in New Issue
Block a user