# Test Associations are Preloaded

**URL:** <https://www.ruby-forum.com/t/test-associations-are-preloaded/103214>\
**Category:** Rails\
**Created:** [May 3, 2007, 12:28am UTC](https://www.ruby-forum.com/t/test-associations-are-preloaded/103214 "2007-05-03T00:28:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nappin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@nappin](https://www.ruby-forum.com/u/nappin)\
**Post date:** [May 3, 2007, 12:28am UTC](https://www.ruby-forum.com/t/test-associations-are-preloaded/103214/1 "2007-05-03T00:28:48Z")

</div>

What’s the best way to test that all assocaitions are preloaded when a  
method is called?

For example, do\_something is a method that makes a db call and preloads  
several associations. Is there a way to write a test that checks that  
calls to do\_something only make one db call?

On the functional level is there a way to write tests that check that  
actions only trigger a certain number of db queries (counting only loads  
and not the select column queries).

Cheers, Ray
