Fix broken test.

This commit is contained in:
Guo Xiang Tan 2017-09-28 16:09:27 +08:00
parent cfed431ef2
commit 5d53eefcab
1 changed files with 9 additions and 3 deletions

View File

@ -157,10 +157,16 @@ class ApplicationController < ActionController::Base
opts ||= {}
show_json_errors = (request.format && request.format.json?) ||
(request.xhr?) ||
((params[:external_id] || '').ends_with? '.json') ||
!(current_user rescue nil)
((params[:external_id] || '').ends_with? '.json')
if show_json_errors
invalid_user =
begin
current_user
rescue Discourse::InvalidAccess
nil
end
if show_json_errors || invalid_user
# HACK: do not use render_json_error for topics#show
if request.params[:controller] == 'topics' && request.params[:action] == 'show'
return render status: status_code, layout: false, plain: (status_code == 404 || status_code == 410) ? build_not_found_page(status_code) : I18n.t(type)