Skip to content
This repository
Browse code

Fix test_any in relations_test.rb, which was failing when relations_t…

…est.rb is run on its own (it passes when the entire suite is run). This is a hacky fix for a problem I didn't quite get to the bottom of, so I'd welcome a better solution...
  • Loading branch information...
commit d6289aadce1b8fa93e799500e52f92ce8d159d6f 1 parent 4e194ed
Jon Leighton jonleighton authored tenderlove committed

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. +8 0 activerecord/test/cases/relations_test.rb
8 activerecord/test/cases/relations_test.rb
@@ -640,6 +640,14 @@ def test_count_complex_chained_relations
640 640 def test_any
641 641 posts = Post.scoped
642 642
  643 + # This test was failing when run on its own (as opposed to running the entire suite).
  644 + # The second line in the assert_queries block was causing visit_Arel_Attributes_Attribute
  645 + # in Arel::Visitors::ToSql to trigger a SHOW TABLES query. Running that line here causes
  646 + # the SHOW TABLES result to be cached so we don't have to do it again in the block.
  647 + #
  648 + # This is obviously a rubbish fix but it's the best I can come up with for now...
  649 + posts.where(:id => nil).any?
  650 +
643 651 assert_queries(3) do
644 652 assert posts.any? # Uses COUNT()
645 653 assert ! posts.where(:id => nil).any?

0 comments on commit d6289aa

Please sign in to comment.
Something went wrong with that request. Please try again.