Skip to content

Commit

Permalink
Merge pull request #19544 from shuhei/fix-parameters-const-missing
Browse files Browse the repository at this point in the history
Return super in ActionController::Parameters.const_missing
  • Loading branch information
fxn committed Mar 28, 2015
2 parents 8bf2825 + 1b0526e commit 8798788
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Parameters < ActiveSupport::HashWithIndifferentAccess
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'abstract_unit'
require 'action_controller/metal/strong_parameters'
require 'minitest/mock'

class AlwaysPermittedParametersTest < ActiveSupport::TestCase
def setup
Expand All @@ -14,7 +15,13 @@ def teardown

test "shows deprecations warning on NEVER_UNPERMITTED_PARAMS" do
assert_deprecated do
ActionController::Parameters::NEVER_UNPERMITTED_PARAMS
ActionController::Parameters::NEVER_UNPERMITTED_PARAMS
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

Expand Down

0 comments on commit 8798788

Please sign in to comment.