diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-22 20:10:29 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-22 20:10:41 +0530 |
commit | ee8c006dac7d76f79fb43df97a4ab8a2ae87b8b2 (patch) | |
tree | 8da7c10f9e96a23e77ab926c28cccb639b6f6267 /activerecord/test | |
parent | c52820ae1550c5e4d3b616c7354ea2c877c24e62 (diff) | |
download | rails-ee8c006dac7d76f79fb43df97a4ab8a2ae87b8b2.tar.gz rails-ee8c006dac7d76f79fb43df97a4ab8a2ae87b8b2.tar.bz2 rails-ee8c006dac7d76f79fb43df97a4ab8a2ae87b8b2.zip |
Allow calling class methods on a Relation
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/named_scope_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 2c34ab787d..894d96346e 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -380,6 +380,15 @@ class NamedScopeTest < ActiveRecord::TestCase assert_deprecated('named_scope has been deprecated') { Topic.named_scope :deprecated_named_scope } end + def test_named_scopes_on_relations + # Topic.replied + approved_topics = Topic.scoped.approved.order('id DESC') + assert_equal topics(:fourth), approved_topics.first + + replied_approved_topics = approved_topics.replied + assert_equal topics(:third), replied_approved_topics.first + end + def test_index_on_named_scope approved = Topic.approved.order('id ASC') assert_equal topics(:second), approved[0] |