Return a 403 instead of 200 when trying to delete a user with posts

See [this commit][1] for more info

[1]: bd352a17bf
This commit is contained in:
Blake Erickson 2018-05-22 16:17:44 -06:00
parent 609804f5ef
commit 3edca8b104
2 changed files with 2 additions and 2 deletions

View File

@ -382,7 +382,7 @@ class Admin::UsersController < Admin::AdminController
render json: {
deleted: false,
message: "User #{user.username} has #{user.post_count} posts, so they can't be deleted."
}
}, status: 403
end
end
end

View File

@ -531,7 +531,7 @@ describe Admin::UsersController do
it "returns an api response that the user can't be deleted because it has posts" do
delete :destroy, params: { id: delete_me.id }, format: :json
expect(response).to be_success
expect(response).to be_forbidden
json = ::JSON.parse(response.body)
expect(json['deleted']).to eq(false)
end