binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.4k stars 133 forks source link

Failing test case for a bug with association conditions #137

Closed isc closed 13 years ago

isc commented 13 years ago

Hi,

First of all, thanks a lot for this great gem. I've encountered a bug seemingly related to scope caching ; the association conditions are dropped on certain occasions. I've written a failing test case that is exhibiting the bug. I've also taken the liberty to write a Gemfile specifying the dependencies needed to work on the gem, as I've had quite a hard time figuring out the correct values (especially the version needed for spec). Can you please let me know if there's a chance that this bug can be easily and promptly fixed by you ? Thanks in advance

ghost commented 13 years ago

Sorry for the delay. I'm pretty sure I know the cause. The internal named scope implementation in ActiveRecord uses sort of a proxy class to keep track of the options being accumulated. If the scope doesn't exist at the time it delegates the call off to the original class, thus losing the options. If it does exist, it keeps accumulating. Notice when you try the assertion a second time, it works.

I'll come up with a proper fix.

ghost commented 13 years ago

This has been fixed and is available in the latest version.

isc commented 13 years ago

Thanks a lot for the fix.