From 45fd668dc563e1ba3a6240910bf1400928255664 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 10 Jun 2020 09:25:58 +0800 Subject: [PATCH] DEV: Render a proper response that can be handled on the client side. --- app/controllers/invites_controller.rb | 8 ++++---- spec/requests/invites_controller_spec.rb | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index ed5b6a01dcd..c429fe32149 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -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 diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rb index 3ba6d09af93..2a5752d7c79 100644 --- a/spec/requests/invites_controller_spec.rb +++ b/spec/requests/invites_controller_spec.rb @@ -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