DEV: Render a proper response that can be handled on the client side.

This commit is contained in:
Guo Xiang Tan 2020-06-10 09:25:58 +08:00
parent f993d8a197
commit 45fd668dc5
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 7 additions and 4 deletions

View File

@ -165,14 +165,14 @@ class InvitesController < ApplicationController
raise Discourse::InvalidParameters.new(:id) if invite.blank?
invite.trash!(current_user)
render body: nil
render json: success_json
end
def rescind_all_invites
guardian.ensure_can_rescind_all_invites!(current_user)
Invite.rescind_all_expired_invites_from(current_user)
render body: nil
render json: success_json
end
def resend_invite
@ -182,7 +182,7 @@ class InvitesController < ApplicationController
invite = Invite.find_by(invited_by_id: current_user.id, email: params[:email])
raise Discourse::InvalidParameters.new(:email) if invite.blank?
invite.resend_invite
render body: nil
render json: success_json
rescue RateLimiter::LimitExceeded
render_json_error(I18n.t("rate_limiter.slow_down"))
@ -192,7 +192,7 @@ class InvitesController < ApplicationController
guardian.ensure_can_resend_all_invites!(current_user)
Invite.resend_all_invites_from(current_user.id)
render body: nil
render json: success_json
end
def upload_csv

View File

@ -70,6 +70,9 @@ describe InvitesController do
it "destroys the invite" do
delete "/invites.json", params: { id: invite.id }
expect(response.status).to eq(200)
invite.reload
expect(invite.trashed?).to be_truthy
end