diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-04 00:26:27 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-04 00:34:21 -0700 |
commit | 94b7328b08fcc55e82bfcaa34a25ae718921ae1c (patch) | |
tree | 4665ff4721ec7e86675265fbbb232f4c39f70628 | |
parent | 316962d0922992fbe756521bd7c94a751aa1253e (diff) | |
download | rails-94b7328b08fcc55e82bfcaa34a25ae718921ae1c.tar.gz rails-94b7328b08fcc55e82bfcaa34a25ae718921ae1c.tar.bz2 rails-94b7328b08fcc55e82bfcaa34a25ae718921ae1c.zip |
Enums shouldn't ruin people's anniversaries
Added a few more methods on Module/Class to the dangerous class methods
blacklist. (Technically, allocate and new are already protected currently because
we happen to redefine them in the current implantation.)
Closes #16792
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/enum_test.rb | 3 | ||||
-rw-r--r-- | activerecord/test/cases/scoping/named_scoping_test.rb | 7 |
3 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index ceee96b3a8..43a3993898 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -31,7 +31,7 @@ module ActiveRecord end } - BLACKLISTED_CLASS_METHODS = %w(private public protected) + BLACKLISTED_CLASS_METHODS = %w(private public protected allocate new name parent superclass) class AttributeMethodCache def initialize diff --git a/activerecord/test/cases/enum_test.rb b/activerecord/test/cases/enum_test.rb index 3b2f0dfe07..346fcab6ea 100644 --- a/activerecord/test/cases/enum_test.rb +++ b/activerecord/test/cases/enum_test.rb @@ -194,7 +194,8 @@ class EnumTest < ActiveRecord::TestCase :valid, # generates #valid?, which conflicts with an AR method :save, # generates #save!, which conflicts with an AR method :proposed, # same value as an existing enum - :public, :private, :protected, # generates a method that conflict with ruby words + :public, :private, :protected, # some important methods on Module and Class + :name, :parent, :superclass ] conflicts.each_with_index do |value, i| diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index 59ec2dd6a4..d3546bd471 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -291,9 +291,12 @@ class NamedScopingTest < ActiveRecord::TestCase :relation, # private class method on AR::Base :new, # redefined class method on AR::Base :all, # a default scope - :public, + :public, # some imporant methods on Module and Class :protected, - :private + :private, + :name, + :parent, + :superclass ] non_conflicts = [ |