FIX: better error message when topic deletion fails

This commit is contained in:
Arpit Jalan 2020-01-15 19:11:41 +05:30
parent ff93c4b2f4
commit 0f8695958b
3 changed files with 4 additions and 1 deletions

View File

@ -557,6 +557,8 @@ class TopicsController < ApplicationController
PostDestroyer.new(current_user, first_post, context: params[:context]).destroy
render body: nil
rescue Discourse::InvalidAccess
render_json_error I18n.t("delete_topic_failed")
end
def recover

View File

@ -266,6 +266,7 @@ en:
request_membership: "Request Membership"
join_group: "Join Group"
deleted_topic: "Oops! This topic has been deleted and is no longer available."
delete_topic_failed: "There was an error deleting that topic. Please contact the site's administrator."
reading_time: "Reading time"
likes: "Likes"

View File

@ -860,7 +860,7 @@ RSpec.describe TopicsController do
it "raises an exception when the user doesn't have permission to delete the topic" do
sign_in(user)
delete "/t/#{topic.id}.json"
expect(response).to be_forbidden
expect(response.status).to eq(422)
end
end