Permalink
Browse files

test for #1570

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 687d7f5 commit a9c69f3bb01976115c5acbfab4967260f7f534d8 Neeraj Singh committed with josevalim Jun 23, 2010
Showing with 6 additions and 0 deletions.
  1. +5 −0 activerecord/test/cases/named_scope_test.rb
  2. +1 −0 activerecord/test/models/post.rb
@@ -9,6 +9,11 @@
class NamedScopeTest < ActiveRecord::TestCase
fixtures :posts, :authors, :topics, :comments, :author_addresses
+ def test_named_scope_with_STI
+ assert_equal 5,Post.with_type_self.count
+ assert_equal 1,SpecialPost.with_type_self.count
+ end
+
def test_implements_enumerable
assert !Topic.find(:all).empty?
@@ -1,4 +1,5 @@
class Post < ActiveRecord::Base
+ named_scope :with_type_self, lambda{{:conditions => ["type=?", self.name]}}
named_scope :containing_the_letter_a, :conditions => "body LIKE '%a%'"
named_scope :ranked_by_comments, :order => "comments_count DESC"
named_scope :limit, lambda {|limit| {:limit => limit} }

0 comments on commit a9c69f3

Please sign in to comment.