diff options
author | Jamis Buck <jamis@37signals.com> | 2005-09-24 23:58:13 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-09-24 23:58:13 +0000 |
commit | 2a35baa0bb4312d95e1340074cce731afedecde0 (patch) | |
tree | e37ca3db4692f54fb728ad4f5fea7a797d2ed5be /activerecord/test/associations_go_eager_test.rb | |
parent | caaf40d5358ae8a2b31949c2af2d94be1be73976 (diff) | |
download | rails-2a35baa0bb4312d95e1340074cce731afedecde0.tar.gz rails-2a35baa0bb4312d95e1340074cce731afedecde0.tar.bz2 rails-2a35baa0bb4312d95e1340074cce731afedecde0.zip |
Wrap :conditions in parentheses to prevent problems with OR's #1871
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2324 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_go_eager_test.rb')
-rw-r--r-- | activerecord/test/associations_go_eager_test.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/activerecord/test/associations_go_eager_test.rb b/activerecord/test/associations_go_eager_test.rb index 750e8bd208..ec088eebb7 100644 --- a/activerecord/test/associations_go_eager_test.rb +++ b/activerecord/test/associations_go_eager_test.rb @@ -20,14 +20,19 @@ class EagerAssociationTest < Test::Unit::TestCase assert post.comments.include?(comments(:greetings)) end + def test_loading_conditions_with_or + posts = authors(:david).posts.find(:all, :include => :comments, :conditions => "comments.body like 'Normal%' OR comments.type = 'SpecialComment'") + assert_nil posts.detect { |p| p.author_id != authors(:david).id }, + "expected to find only david's posts" + end + def test_with_ordering - posts = Post.find(:all, :include => :comments, :order => "posts.id DESC") - assert_equal posts(:sti_habtm), posts[0] - assert_equal posts(:sti_post_and_comments), posts[1] - assert_equal posts(:sti_comments), posts[2] - assert_equal posts(:authorless), posts[3] - assert_equal posts(:thinking), posts[4] - assert_equal posts(:welcome), posts[5] + list = Post.find(:all, :include => :comments, :order => "posts.id DESC") + [:eager_other, :sti_habtm, :sti_post_and_comments, :sti_comments, + :authorless, :thinking, :welcome + ].each_with_index do |post, index| + assert_equal posts(post), list[index] + end end def test_loading_with_multiple_associations @@ -48,7 +53,7 @@ class EagerAssociationTest < Test::Unit::TestCase def test_eager_association_loading_with_belongs_to comments = Comment.find(:all, :include => :post) - assert_equal 9, comments.length + assert_equal 10, comments.length titles = comments.map { |c| c.post.title } assert titles.include?(posts(:welcome).title) assert titles.include?(posts(:sti_post_and_comments).title) |