diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2013-12-17 11:29:23 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2013-12-17 11:29:23 -0700 |
commit | 2b096c7170bd8b4892fb3902741c8a4c21e962b2 (patch) | |
tree | a89771f47e4d2c9aed0c63c3092346b58bd610f5 /activerecord/test/cases | |
parent | 83e4dde41a09bf501c41386f874a83b2f50af5f3 (diff) | |
parent | d4ee09cda135da9c36a5ddadd2d8c2d35c116be3 (diff) | |
download | rails-2b096c7170bd8b4892fb3902741c8a4c21e962b2.tar.gz rails-2b096c7170bd8b4892fb3902741c8a4c21e962b2.tar.bz2 rails-2b096c7170bd8b4892fb3902741c8a4c21e962b2.zip |
Merge pull request #13314 from laurocaetano/blacklist_array_methods
Create a blacklist to disallow mutator methods to be delegated to Array
Conflicts:
guides/source/upgrading_ruby_on_rails.md
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relation/delegation_test.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb index f295ccbc6a..9b2bfed039 100644 --- a/activerecord/test/cases/relation/delegation_test.rb +++ b/activerecord/test/cases/relation/delegation_test.rb @@ -26,15 +26,22 @@ module ActiveRecord end module DelegationWhitelistBlacklistTests - ActiveRecord::Delegation::ARRAY_DELEGATES.each do |method| + ARRAY_DELEGATES = [ + :+, :-, :|, :&, :[], + :all?, :collect, :detect, :each, :each_cons, :each_with_index, + :exclude?, :find_all, :flat_map, :group_by, :include?, :length, + :map, :none?, :one?, :partition, :reject, :reverse, + :sample, :second, :sort, :sort_by, :third, + :to_ary, :to_set, :to_xml, :to_yaml + ] + + ARRAY_DELEGATES.each do |method| define_method "test_delegates_#{method}_to_Array" do assert_respond_to target, method end end - [:compact!, :flatten!, :reject!, :reverse!, :rotate!, - :shuffle!, :slice!, :sort!, :sort_by!, :delete_if, - :keep_if, :pop, :shift, :delete_at, :compact].each do |method| + ActiveRecord::Delegation::BLACKLISTED_ARRAY_METHODS.each do |method| define_method "test_#{method}_is_not_delegated_to_Array" do assert_raises(NoMethodError) { call_method(target, method) } end |