diff options
| author | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-06 04:37:54 +0900 | 
|---|---|---|
| committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-02-06 04:58:45 +0900 | 
| commit | 0f3e8e1ebb1255bfda455753b1b2087315f46fdc (patch) | |
| tree | aef0f617f17d55c8ab98675fcb8440cdb6a0e01c /activerecord | |
| parent | 7caea98e189c02721b2e944a074c405b033852eb (diff) | |
| download | rails-0f3e8e1ebb1255bfda455753b1b2087315f46fdc.tar.gz rails-0f3e8e1ebb1255bfda455753b1b2087315f46fdc.tar.bz2 rails-0f3e8e1ebb1255bfda455753b1b2087315f46fdc.zip  | |
Relation no longer respond to Arel methods
This follows up d97980a16d76ad190042b4d8578109714e9c53d0.
Diffstat (limited to 'activerecord')
| -rw-r--r-- | activerecord/lib/active_record/relation/delegation.rb | 2 | ||||
| -rw-r--r-- | activerecord/test/cases/relation/delegation_test.rb | 10 | ||||
| -rw-r--r-- | activerecord/test/cases/relations_test.rb | 15 | 
3 files changed, 8 insertions, 19 deletions
diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb index 6e8a1fcad4..f7c3b3783f 100644 --- a/activerecord/lib/active_record/relation/delegation.rb +++ b/activerecord/lib/active_record/relation/delegation.rb @@ -132,7 +132,7 @@ module ActiveRecord      private        def respond_to_missing?(method, _) -        super || @klass.respond_to?(method) || arel.respond_to?(method) +        super || @klass.respond_to?(method)        end    end  end diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb index b600c999a6..63ae438de3 100644 --- a/activerecord/test/cases/relation/delegation_test.rb +++ b/activerecord/test/cases/relation/delegation_test.rb @@ -5,7 +5,7 @@ require "models/post"  require "models/comment"  module ActiveRecord -  module ArrayDelegationTests +  module DelegationTests      ARRAY_DELEGATES = [        :+, :-, :|, :&, :[], :shuffle,        :all?, :collect, :compact, :detect, :each, :each_cons, :each_with_index, @@ -21,10 +21,14 @@ module ActiveRecord          assert_respond_to target, method        end      end + +    def test_not_respond_to_arel_method +      assert_not_respond_to target, :exists +    end    end    class DelegationAssociationTest < ActiveRecord::TestCase -    include ArrayDelegationTests +    include DelegationTests      def target        Post.new.comments @@ -32,7 +36,7 @@ module ActiveRecord    end    class DelegationRelationTest < ActiveRecord::TestCase -    include ArrayDelegationTests +    include DelegationTests      def target        Comment.all diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 756eeca35f..6b5b877260 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -480,21 +480,6 @@ class RelationTest < ActiveRecord::TestCase      assert_nothing_raised { Topic.reorder([]) }    end -  def test_respond_to_delegates_to_arel -    relation = Topic.all -    fake_arel = Struct.new(:responds) { -      def respond_to?(method, access = false) -        responds << [method, access] -      end -    }.new [] - -    relation.extend(Module.new { attr_accessor :arel }) -    relation.arel = fake_arel - -    relation.respond_to?(:matching_attributes) -    assert_equal [:matching_attributes, false], fake_arel.responds.first -  end -    def test_respond_to_dynamic_finders      relation = Topic.all  | 
