mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix test_any in relations_test.rb, which was failing when relations_test.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...
This commit is contained in:
parent
4e194ed1e6
commit
d6289aadce
1 changed files with 8 additions and 0 deletions
|
@ -640,6 +640,14 @@ class RelationTest < ActiveRecord::TestCase
|
|||
def test_any
|
||||
posts = Post.scoped
|
||||
|
||||
# This test was failing when run on its own (as opposed to running the entire suite).
|
||||
# The second line in the assert_queries block was causing visit_Arel_Attributes_Attribute
|
||||
# in Arel::Visitors::ToSql to trigger a SHOW TABLES query. Running that line here causes
|
||||
# the SHOW TABLES result to be cached so we don't have to do it again in the block.
|
||||
#
|
||||
# This is obviously a rubbish fix but it's the best I can come up with for now...
|
||||
posts.where(:id => nil).any?
|
||||
|
||||
assert_queries(3) do
|
||||
assert posts.any? # Uses COUNT()
|
||||
assert ! posts.where(:id => nil).any?
|
||||
|
|
Loading…
Reference in a new issue