aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-22 20:14:37 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-22 20:14:37 +0530
commit4afd9702fe111a5cbaa0d9572e7661c90b188d49 (patch)
tree635dd9cd0d93f5feb4421af1a84f1bcc73d70ede /activerecord
parentee8c006dac7d76f79fb43df97a4ab8a2ae87b8b2 (diff)
downloadrails-4afd9702fe111a5cbaa0d9572e7661c90b188d49.tar.gz
rails-4afd9702fe111a5cbaa0d9572e7661c90b188d49.tar.bz2
rails-4afd9702fe111a5cbaa0d9572e7661c90b188d49.zip
Relation should respond to class methods
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation.rb2
-rw-r--r--activerecord/test/cases/relations_test.rb5
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? }