1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Relation should respond to class methods

This commit is contained in:
Pratik Naik 2010-01-22 20:14:37 +05:30
parent ee8c006dac
commit 4afd9702fe
2 changed files with 6 additions and 1 deletions

View file

@ -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)

View file

@ -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? }