diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 8 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 84cd739781..b69a12bc7b 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -73,6 +73,14 @@ module ActiveRecord end end + def respond_to?(method) + if @relation.respond_to?(method) || Array.instance_methods.include?(method.to_s) + true + else + super + end + end + private def method_missing(method, *args, &block) if @relation.respond_to?(method) diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index b017570b45..6a39aa6e40 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -71,5 +71,13 @@ class RelationTest < ActiveRecord::TestCase ).to_a assert_equal 1, person_with_reader_and_post.size end + + def test_relation_responds_to_delegated_methods + relation = Topic.all + + ["map", "uniq", "sort", "insert", "delete", "update"].each do |method| + assert relation.respond_to?(method) + end + end end |