diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-06 15:23:11 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-06 15:23:25 -0700 |
commit | e1596be32363122f12777ce09e654ae58f262eb4 (patch) | |
tree | 726d7df23cfe6276df7e6893513fdd4a72cf38e9 | |
parent | d082a9a2b803c2cf530c6b6bdb8a5c4f19f36982 (diff) | |
download | rails-e1596be32363122f12777ce09e654ae58f262eb4.tar.gz rails-e1596be32363122f12777ce09e654ae58f262eb4.tar.bz2 rails-e1596be32363122f12777ce09e654ae58f262eb4.zip |
test to ensure that respond_to? delegates to arel
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 02c8c60873..ac7b501bb7 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -192,6 +192,25 @@ class RelationTest < ActiveRecord::TestCase 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 |