harleyttd/auditable — pull request #31 by jameslovejoy (2014-06-17 02:30:36+00:00)
Title: When audits have the same timestamp, only diff against older audits (by ID)

We've run into an issue where the diffs aren't appearing correctly when there are multiple audits with the same timestamp.

Because the condition currently checks `created_at <= ? AND id != ?`, it may compare the current audit with a newer one if the timestamps are equal, instead of comparing it with the previous audit as we're expecting. I've added a test case for this scenario which hopefully explains the expected behavior more clearly than I can describe here. By changing the condition to `created_at <= ? AND id < ?` we ensure that we're only comparing the current audit against an older state.