Permalink
Browse files

Relation should respond to class methods

  • Loading branch information...
1 parent ee8c006 commit 4afd9702fe111a5cbaa0d9572e7661c90b188d49 @lifo lifo committed Jan 22, 2010
Showing with 6 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/relation.rb
  2. +5 −0 activerecord/test/cases/relations_test.rb
@@ -32,7 +32,7 @@ def create!(*args, &block)
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 @@ def test_respond_to_dynamic_finders
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? }

0 comments on commit 4afd970

Please sign in to comment.