make tests pass on Ruby 2.2

Apparently we've been using a buggy feature for the past 6 years:

  https://bugs.ruby-lang.org/issues/9593
passing an ActiveRecord object to `exists?` is deprecated.

Pass the id of the object to the method by calling `.id` on the AR
object.
passing an instance of an AR object to `find` is deprecated

please pass the id of the AR object by calling `.id` on the model first.
Make select_all on query cache accept a Relation without binds.

[fixes #14361]
[related #13886]