Automatically flag someone as a spammer if their posts get at least X spam flags from N users while their trust level is 'new user'. Staff can clear and set this status from the user record in admin.

This commit is contained in:
Neil Lalonde
2013-05-31 11:41:40 -04:00
parent 1e7279f0ea
commit c4904aacc0
20 changed files with 585 additions and 32 deletions

View File

@ -81,7 +81,7 @@ describe Admin::UsersController do
context '.revoke_admin' do
before do
@another_admin = Fabricate(:another_admin)
@another_admin = Fabricate(:admin)
end
it 'raises an error unless the user can revoke access' do
@ -189,6 +189,51 @@ describe Admin::UsersController do
end
end
context 'block' do
before do
@user = Fabricate(:user)
end
it "raises an error when the user doesn't have permission" do
Guardian.any_instance.expects(:can_block_user?).with(@user).returns(false)
SpamRulesEnforcer.expects(:punish!).never
xhr :put, :block, user_id: @user.id
response.should be_forbidden
end
it "returns a 403 if the user doesn't exist" do
xhr :put, :block, user_id: 123123
response.should be_forbidden
end
it "punishes the user for spamming" do
SpamRulesEnforcer.expects(:punish!).with(@user)
xhr :put, :block, user_id: @user.id
end
end
context 'unblock' do
before do
@user = Fabricate(:user)
end
it "raises an error when the user doesn't have permission" do
Guardian.any_instance.expects(:can_unblock_user?).with(@user).returns(false)
xhr :put, :unblock, user_id: @user.id
response.should be_forbidden
end
it "returns a 403 if the user doesn't exist" do
xhr :put, :unblock, user_id: 123123
response.should be_forbidden
end
it "punishes the user for spamming" do
SpamRulesEnforcer.expects(:clear).with(@user)
xhr :put, :unblock, user_id: @user.id
end
end
end
end