first take at making user permission migration faster
make castle_gate tests run with ruby 1.9 and rails 4.0 around
allow grant_access :public => [] to work

This should obviously be a noop but it's very helpful for migration scripts not always to test if there are permissions
do not load associations just for comparing to a symbol
let's have one callback per grant or revoke

not one per granted or revoked gate
only call after_{grant,revoke} callbacks if key changed
again avoid instantiating the proxy for a comparison
make sure the after_{grant,revoke}_access callbacks get an array
removing redundant may_pester and may_be_pestered_by
added set_access! to castle instance methods

In contrast to grant_access one will remove all gates set so far and not apply defaults.

little bit of refactoring
no callbacks from set_access! - added WARNING

This is a lower level function than the grant and revoke ones. This is meant to be used in migrations from other permission systems.
use the new set_access!

This way defaults will not be added and callbacks will not be run.

We take care of a consistent migration ourselves.
peers should either have public or friends gates access
fixed expression to ensure gates is an array
minor: the task is called cg:upgrade:user_permissions - plural
unit tests: use require_relative instead of "require" - this makes running tests on their own work again
use may?(...) instead of may_pester? / may_be_pestered_by? in unit tests
explicitly specify which "id" column is meant in handle validations and PageHistory
there are no passive be_pestered_by permissions - removing tests
rewriting with_access to use group() instead of select(DISTINCT...)

We also need to overwrite count in that case so it does not return a hash