From d5dbe6322f86873d3d7a649877369c5249d7e70c Mon Sep 17 00:00:00 2001 From: Ryan Bates Date: Tue, 27 May 2008 08:02:41 -0700 Subject: [PATCH] added test for calling named scope in class --- activerecord/test/cases/named_scope_test.rb | 5 ++++- activerecord/test/models/topic.rb | 5 +++++ 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 8f2fc53..fd36c71 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -145,5 +145,8 @@ class NamedScopeTest < ActiveRecord::TestCase topics.last(:order => 'title') end end - + + def test_named_scope_in_class_method_should_maintain_scope + assert_equal Topic.replied.approved, Topic.replied.approved_through_class_method + end end diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index f63e862..78617a2 100755 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -42,6 +42,11 @@ class Topic < ActiveRecord::Base def topic_id id end + + # trivial method for testing calling named scope in class method + def self.approved_through_class_method + approved + end protected def approved=(val) -- 1.5.4