A podmin can now disable a spam account from the interface.

This commit is contained in:
Maxwell Salzberg 2014-06-23 19:32:07 -07:00 committed by Florian Staudacher
parent 5a3d329703
commit cc53e1762b
4 changed files with 22 additions and 0 deletions

View file

@ -10,6 +10,12 @@ class AdminsController < ApplicationController
@users ||= [] @users ||= []
end end
def remove_spammer
user = User.find(params[:user_id])
user.close_account!
redirect_to root_url, notice:"this account will be deleted in a few moments"
end
def admin_inviter def admin_inviter
inviter = InvitationCode.default_inviter_or(current_user) inviter = InvitationCode.default_inviter_or(current_user)
email = params[:identifier] email = params[:identifier]

View file

@ -90,3 +90,7 @@
%br %br
%br %br
- if current_user.admin? && person.owner.present?
= link_to 'Disable Account', remove_spammer_path(user_id:person.owner.id), method: :delete, data:{confirm:'Are you sure you want to disable this account? It will delete all data associated.'}

View file

@ -128,6 +128,7 @@ Diaspora::Application.routes.draw do
get :admin_inviter get :admin_inviter
get :weekly_user_stats get :weekly_user_stats
get :correlations get :correlations
delete :remove_spammer
get :stats, :as => 'pod_stats' get :stats, :as => 'pod_stats'
get "add_invites/:invite_code_id" => 'admins#add_invites', :as => 'add_invites' get "add_invites/:invite_code_id" => 'admins#add_invites', :as => 'add_invites'
end end

View file

@ -103,6 +103,17 @@ describe AdminsController do
end end
end end
describe '#remove_spammer' do
it 'it queues a job to disable the given account' do
other_user = FactoryGirl.create :user
User.stub(:find).and_return(other_user)
delete :remove_spammer, user_id: other_user.id
other_user.should_receive(:close_account)
end
end
describe '#stats' do describe '#stats' do
before do before do
Role.add_admin(@user.person) Role.add_admin(@user.person)