Add test for querying on a join-model with particular criteria