Skip to content

Commit

Permalink
add test for named_scope with lambda and :include (references #229)
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Oct 7, 2008
1 parent 1449867 commit 7e3a90b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/finder_test.rb
Expand Up @@ -261,6 +261,12 @@ def test_paginate_in_named_scope_on_has_many_association
assert_equal 1, entries.total_entries, 'only one topic should be found'
end
end

def test_named_scope_with_include
project = projects(:active_record)
entries = project.topics.with_replies_starting_with('AR ').paginate(:page => 1, :per_page => 1)
assert_equal 1, entries.size
end

## misc ##

Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/topic.rb
Expand Up @@ -3,4 +3,8 @@ class Topic < ActiveRecord::Base
belongs_to :project

named_scope :mentions_activerecord, :conditions => ['topics.title LIKE ?', '%ActiveRecord%']

named_scope :with_replies_starting_with, lambda { |text|
{ :conditions => "replies.content LIKE '#{text}%' ", :include => :replies }
}
end

0 comments on commit 7e3a90b

Please sign in to comment.