mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:14:12 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user