Includes HABTM returns correct size now. Fixes #16032 and #15244 for master

    Includes HABTM returns correct size now. It's caused by the join dependency only instantiates one HABTM object because the join table hasn't a primary key.
    Updated commit and test fixed from @bigxiang commit dbaa837

    Fixes #16032.

    Examples:

        before:

        Project.first.salaried_developers.size # => 3
        Project.includes(:salaried_developers).first.salaried_developers.size # => 1

        after:

        Project.first.salaried_developers.size # => 3
        Project.includes(:salaried_developers).first.salaried_developers.size # => 3
Not sure, maybe the bug it's on other file and this is only a workaround. I will explain what I saw.

When preloading a HABTM association with string conditions, like developers_named_david, reflection_scope.values[:references] was nil, and after running that line scope.eager_loading? returned true. In this case SQL was right.

However, when preloading a HABTM association with hashed conditions, like developers_named_david_with_hash_conditions, reflection_scope.values[:references] was [], and after running that line scope.eager_loading? returned false. In this case SQL was wrong and exception was raised.

I think calling references! with nil or [] shouldn't change anything, but I don't know if changing that could break something, so I thought this would be a safer change.

Also, I tried to call references! only if reflection_scope.values[:references].present? but it failed for both associations.