has_many through with dynamic conditions

Fixes #16128

This bug was introduced in rails@c35e438
so it's present from 4.1.2-rc1 and after.

rails@c35e438 merges any relation
scopes passed as proc objects to the relation, but does *not* take into account the case where
the lambda requires an argument (ie. the current record).

To reproduce see https://gist.github.com/Agis-/5f1f0d664d2cd08dfb9b