Add ability to destroy a user with 0 posts
This commit is contained in:
parent
8014d7fd25
commit
651cfba93f
21 changed files with 412 additions and 57 deletions
spec/controllers/admin
|
@ -161,6 +161,34 @@ describe Admin::UsersController do
|
|||
end
|
||||
end
|
||||
|
||||
context '.destroy' do
|
||||
before do
|
||||
@delete_me = Fabricate(:user)
|
||||
end
|
||||
|
||||
it "raises an error when the user doesn't have permission" do
|
||||
Guardian.any_instance.expects(:can_delete_user?).with(@delete_me).returns(false)
|
||||
xhr :delete, :destroy, id: @delete_me.id
|
||||
response.should be_forbidden
|
||||
end
|
||||
|
||||
it "returns a 403 if the user doesn't exist" do
|
||||
xhr :delete, :destroy, id: 123123
|
||||
response.should be_forbidden
|
||||
end
|
||||
|
||||
it "returns an error if the user has posts" do
|
||||
Fabricate(:post, user: @delete_me)
|
||||
xhr :delete, :destroy, id: @delete_me.id
|
||||
response.should be_forbidden
|
||||
end
|
||||
|
||||
it "deletes the user record" do
|
||||
UserDestroyer.any_instance.expects(:destroy).returns(true)
|
||||
xhr :delete, :destroy, id: @delete_me.id
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Reference in a new issue