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:
parent
ee8c006dac
commit
4afd9702fe
2 changed files with 6 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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? }
|
||||
|
|
Loading…
Reference in a new issue