From d9fca84d218f0ed784c7bf6470df42d41838e507 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 6 May 2017 06:02:01 +0900 Subject: Deprecate delegating to `arel` in `Relation` Active Record doesn't rely delegating to `arel` in the internal since 425f2ca. The delegation is a lower priority than delegating to `klass`, so it is pretty unclear which method is delegated to `arel`. For example, `bind_values` method was removed at b06f64c (a series of changes https://github.com/rails/rails/compare/79f71d3...b06f64c). But a relation still could respond to the method because `arel` also have the same named method (#28976). Removing the delegation will achieve predictable behavior. --- activerecord/test/cases/relation/delegation_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb index cb6e4d76d3..3b15f051b2 100644 --- a/activerecord/test/cases/relation/delegation_test.rb +++ b/activerecord/test/cases/relation/delegation_test.rb @@ -21,8 +21,22 @@ module ActiveRecord end end + module DeprecatedArelDelegationTests + AREL_METHODS = [ + :with, :orders, :froms, :project, :projections, :taken, :constraints, :exists, :locked, :where_sql, + :ast, :source, :join_sources, :to_dot, :bind_values, :create_insert, :create_true, :create_false + ] + + def test_deprecate_arel_delegation + AREL_METHODS.each do |method| + assert_deprecated { target.public_send(method) } + end + end + end + class DelegationAssociationTest < ActiveRecord::TestCase include DelegationWhitelistTests + include DeprecatedArelDelegationTests fixtures :posts @@ -33,6 +47,7 @@ module ActiveRecord class DelegationRelationTest < ActiveRecord::TestCase include DelegationWhitelistTests + include DeprecatedArelDelegationTests fixtures :comments -- cgit v1.2.3