tchandy/octopus — pull request #247 by krasnoukhov (2014-05-22 14:07:02+00:00)
Title: Relation proxy changes

Hey @nickmarden! I've run into a bug with Octopus which I was struggling to fix during a few hours, and I'm sending this PR hoping you can clarify some things for me.

Consider this code:

```
@client = Client.using(:canada).create!
@client.items << Item.using(:canada).create!
@relation = @client.items
@client.items.where(id: @relation).count.should eq(1)
```

The last line raises ```**NoMethodError**: undefined method `visit_Octopus_RelationProxy' for #``` on master. Apparently, this is caused by ```RelationProxy```.

I was trying to fix that and after some time of debugging I realized that the tests you've introduced in [this commit](https://github.com/curebit/octopus/commit/f29c32a0245028303da89e2f8cdbdd8a1684d7c0) are passing even when Octopus is set to not use ```RelationProxy``` instead of plain ```ActiveRecord::Relation```. I'm attaching commit that proves that and also adds _previously_ failing spec describing my problem (using ```where``` statement with relation as argument).

So, I would be really great if you can give me more details on what is ```RelationProxy``` purpose and how I can I properly test it, this would help me a lot in order to fix the bug described above.

Thank you. Cheers!