FIX: better error message when topic deletion fails
This commit is contained in:
parent
ff93c4b2f4
commit
0f8695958b
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue