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

Merge pull request #19544 from shuhei/fix-parameters-const-missing

Return super in ActionController::Parameters.const_missing
This commit is contained in:
Xavier Noria 2015-03-28 10:01:25 +01:00
commit 8798788c65
2 changed files with 9 additions and 2 deletions

View file

@ -117,7 +117,7 @@ module ActionController
self.always_permitted_parameters = %w( controller action )
def self.const_missing(const_name)
super unless const_name == :NEVER_UNPERMITTED_PARAMS
return super unless const_name == :NEVER_UNPERMITTED_PARAMS
ActiveSupport::Deprecation.warn(<<-MSG.squish)
`ActionController::Parameters::NEVER_UNPERMITTED_PARAMS` has been deprecated.
Use `ActionController::Parameters.always_permitted_parameters` instead.

View file

@ -1,5 +1,6 @@
require 'abstract_unit'
require 'action_controller/metal/strong_parameters'
require 'minitest/mock'
class AlwaysPermittedParametersTest < ActiveSupport::TestCase
def setup
@ -18,6 +19,12 @@ class AlwaysPermittedParametersTest < ActiveSupport::TestCase
end
end
test "returns super on missing constant other than NEVER_UNPERMITTED_PARAMS" do
ActionController::Parameters.superclass.stub :const_missing, "super" do
assert_equal "super", ActionController::Parameters::NON_EXISTING_CONSTANT
end
end
test "permits parameters that are whitelisted" do
params = ActionController::Parameters.new({
book: { pages: 65 },