tcocca/acts_as_follower — pull request #17 by peterjm (2011-10-12 19:47:46+00:00)
Title: Change includes(:following) to joins(:following) in following_by_type

I changed the `includes(:following)` to a `joins(:following)` in `Follower#following_by_type`. The reason for this was because we don't want to actually load the Follow objects, just use them as a WHERE condition. I ran into a problem with the current implementation when I was trying to use the SQL generated by `following_by_type` as a subquery in MySQL.

The test change requires slightly more explanation. As explained in detail in https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5060, combining COUNT and LIMIT is generally not supported (it doesn't work in Rails 3.0.x, but does seem to be working for me in Rails 3.1). Changing the `includes` to a `joins` caused the test to break, but the fact that it was originally passing was dubious, anyway. By explicitly converting the results to an array, test the becomes more robust.