1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #28897 from rafaelfranca/fix-name-error-error-page

Do not try to encoding the parameters when the controller is not defined
This commit is contained in:
Aaron Patterson 2017-04-26 20:54:12 -07:00 committed by GitHub
commit c5663c4282
2 changed files with 21 additions and 1 deletions

View file

@ -85,7 +85,7 @@ module ActionDispatch
def set_binary_encoding(params)
action = params[:action]
if controller_class.binary_params_for?(action)
if binary_params_for?(action)
ActionDispatch::Request::Utils.each_param_value(params) do |param|
param.force_encoding ::Encoding::ASCII_8BIT
end
@ -93,6 +93,12 @@ module ActionDispatch
params
end
def binary_params_for?(action)
controller_class.binary_params_for?(action)
rescue NameError
false
end
def parse_formatted_parameters(parsers)
return yield if content_length.zero? || content_mime_type.nil?

View file

@ -100,6 +100,20 @@ module ApplicationTests
end
end
test "routing to an nonexistent controller when action_dispatch.show_exceptions and consider_all_requests_local are set shows diagnostics" do
app_file "config/routes.rb", <<-RUBY
Rails.application.routes.draw do
resources :articles
end
RUBY
app.config.action_dispatch.show_exceptions = true
app.config.consider_all_requests_local = true
get "/articles"
assert_match "<title>Action Controller: Exception caught</title>", last_response.body
end
test "displays diagnostics message when exception raised in template that contains UTF-8" do
controller :foo, <<-RUBY
class FooController < ActionController::Base