Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

test for #1570

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit a9c69f3bb01976115c5acbfab4967260f7f534d8 1 parent 687d7f5
@neerajdotname neerajdotname authored josevalim committed
View
5 activerecord/test/cases/named_scope_test.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?
View
1  activerecord/test/models/post.rb
@@ -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} }
Please sign in to comment.
Something went wrong with that request. Please try again.