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:
parent
609804f5ef
commit
3edca8b104
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue