CanCanCommunity/cancancan — pull request #72 by scpike (2014-06-04 16:36:51+00:00)
Title: Split out separate adapters for AR 3 and AR 4

I ran into https://github.com/CanCanCommunity/cancancan/issues/26 when upgrading a rails app to 4.1 and saw that you'd mentioned wanting to solve this by splitting apart adapters for AR3 and AR4. Here's my attempt. I'm happy to re-write this code if you give me pointers to how you'd prefer it go.

This detects the ActiveRecord version and load different adapters for < 4 and > 4. Shared code (which is most of it) is still in `ActiveRecordAdapter`, though that's been converted into a module so that both the adapters could remain direct subclasses of AbstractAdapter (not sure if that was a good idea or not, but it's working).

I moved the metawhere stuff into the AR3 adapter, since that's not supported in AR4 (it's not even supported in 3.1, I don't think, but I don't use it).

I used the same approach from @tdg5 in https://github.com/CanCanCommunity/cancancan/pull/39 to add `references` when you want to force an outer join in AR4.

I think I figured out how to use Appraisal and added gemsets for 4.0 and 4.1. I didn't add any new specs because this test (https://github.com/CanCanCommunity/cancancan/blob/develop/spec/cancan/model_adapters/active_record_adapter_spec.rb#L131) was already failing once I tried on 4.1 (4.0 passed all tests).

I did update that test file to work for both the AR3 and AR4 adapters, rather than copying all the specs into another test file.