aq1018/mongoid-history — pull request #45 by cgriego (2012-09-27 20:27:51+00:00)
Title: Fix intermittent hash ordering issue with #history_tracks

The query generated by #history_tracks looks for an exact match in the association_chain array, including the order of the keys in the documents in the array. The hash order is indeterminate in Ruby 1.8 so sometimes the query works and sometimes it fails. Actually depending on the data in the database, it might find half the entries part of the time and other half the rest of the time. Using $elemMatch resolves the issue by making the query work regardless of the order of the keys in the database. Because the key order is indeterminate, I was unable to create a stable automated test.

This patch is made against the 2.4 branch. This fix should apply equally well to 0.3.0 because any app that used the earlier version will have mixed key orders in their database and they should be able to find them with 0.3.0 on 1.9.