The comparison between `Relation` and `CollectionProxy` should be consistent.

Before this patch, it was behaving this way:

```ruby
author.posts == Post.where(author_id: author.id)
# => true
Post.where(author_id: author.id) == author.posts
# => false
```

This patch checks if the object given to `Relation#==` is a `CollectionProxy` and then call `to_a` on it to do the comparison.

Fixes #13506