diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index fa99e3f891..1a96cdad17 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -32,7 +32,7 @@ module ActiveRecord end def respond_to?(method, include_private = false) - return true if arel.respond_to?(method, include_private) || Array.method_defined?(method) + return true if arel.respond_to?(method, include_private) || Array.method_defined?(method) || @klass.respond_to?(method, include_private) if match = DynamicFinderMatch.match(method) return true if @klass.send(:all_attributes_exists?, match.attribute_names) diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index d34c9b4895..1e345399f5 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -164,6 +164,11 @@ class RelationTest < ActiveRecord::TestCase end end + def test_respond_to_class_methods_and_named_scopes + assert DeveloperOrderedBySalary.scoped.respond_to?(:all_ordered_by_name) + assert Topic.scoped.respond_to?(:by_lifo) + end + def test_find_with_readonly_option Developer.scoped.each { |d| assert !d.readonly? } Developer.scoped.readonly.each { |d| assert d.readonly? } |