diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-04-02 17:34:48 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-04-02 17:38:02 +0100 |
commit | b77dd218ce845f01753d02fcbc2605c9a5ee93e1 (patch) | |
tree | ea07dbe6965bd31ea7d066e04f7dad0e67e62f31 /activerecord/test/cases | |
parent | bc7da9b77d6347eeccefa2c735b2f236a08eea57 (diff) | |
download | rails-b77dd218ce845f01753d02fcbc2605c9a5ee93e1.tar.gz rails-b77dd218ce845f01753d02fcbc2605c9a5ee93e1.tar.bz2 rails-b77dd218ce845f01753d02fcbc2605c9a5ee93e1.zip |
Add Relation extensions
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 1e345399f5..7b9e680c02 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -572,4 +572,20 @@ class RelationTest < ActiveRecord::TestCase assert_equal Post.all, all_posts.all end + def test_anonymous_extension + relation = Post.where(:author_id => 1).order('id ASC') do + def author + 'lifo' + end + end + + assert_equal "lifo", relation.author + assert_equal "lifo", relation.limit(1).author + end + + def test_named_extension + relation = Post.where(:author_id => 1).order('id ASC').extending(Post::NamedExtension) + assert_equal "lifo", relation.author + assert_equal "lifo", relation.limit(1).author + end end |