parent
8dae98a3f6
commit
6baea9948b
|
@ -167,6 +167,12 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
render_json_error I18n.t(opts[:custom_message] || type), type: type, status: status_code
|
render_json_error I18n.t(opts[:custom_message] || type), type: type, status: status_code
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
|
current_user
|
||||||
|
rescue Discourse::InvalidAccess
|
||||||
|
return render plain: I18n.t(type), status: status_code
|
||||||
|
end
|
||||||
|
|
||||||
render html: build_not_found_page(status_code, opts[:include_ember] ? 'application' : 'no_ember')
|
render html: build_not_found_page(status_code, opts[:include_ember] ? 'application' : 'no_ember')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1059,9 +1059,10 @@ describe TopicsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns 403 for an invalid key' do
|
it 'returns 403 for an invalid key' do
|
||||||
|
[:json, :html].each do |format|
|
||||||
get :show, params: {
|
get :show, params: {
|
||||||
topic_id: topic.id, slug: topic.slug, api_key: "bad"
|
topic_id: topic.id, slug: topic.slug, api_key: "bad"
|
||||||
}, format: :json
|
}, format: format
|
||||||
|
|
||||||
expect(response.code.to_i).to be(403)
|
expect(response.code.to_i).to be(403)
|
||||||
expect(response.body).to eq(I18n.t("invalid_access"))
|
expect(response.body).to eq(I18n.t("invalid_access"))
|
||||||
|
@ -1069,6 +1070,7 @@ describe TopicsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#posts' do
|
describe '#posts' do
|
||||||
let(:topic) { Fabricate(:post).topic }
|
let(:topic) { Fabricate(:post).topic }
|
||||||
|
|
Loading…
Reference in New Issue