Permalink
Browse files

test to ensure that respond_to? delegates to arel

  • Loading branch information...
tenderlove committed Aug 6, 2010
1 parent a897a1f commit 001a5747858f2636cce48891ebc5af132c843b05
Showing with 19 additions and 0 deletions.
  1. +19 −0 activerecord/test/cases/relations_test.rb
@@ -192,6 +192,25 @@ def test_scoped_responds_to_delegated_methods
end
end
+ def test_respond_to_delegates_to_relation
+ relation = Topic.scoped
+ fake_arel = Struct.new(:responds) {
+ def respond_to? method, access = false
+ responds << [method, access]
+ end
+ }.new []
+
+ relation.extend(Module.new { attr_accessor :arel })
+ relation.arel = fake_arel
+
+ relation.respond_to?(:matching_attributes)
+ assert_equal [:matching_attributes, false], fake_arel.responds.first
+
+ fake_arel.responds = []
+ relation.respond_to?(:matching_attributes, true)
+ assert_equal [:matching_attributes, true], fake_arel.responds.first
+ end
+
def test_respond_to_dynamic_finders
relation = Topic.scoped

0 comments on commit 001a574

Please sign in to comment.