westonganger / active_snapshot

Simplified snapshots and restoration for ActiveRecord models and associations with a transparent white-box implementation
MIT License
103 stars 16 forks source link

Fix multiple children snapshot #1

Closed muxahu3bm closed 3 years ago

muxahu3bm commented 3 years ago

There is wrong working with multiple model's children. In the case when we defined:

has_snapshot_children do
  instance = self.class.includes(:comments, :notes).find(id)

  {
    comments: instance.comments,
    notes: instance.notes
  }
end

The result will be contained only first instance relation - comments.

westonganger commented 3 years ago

Oh no that was a stupid mistake on my part. Thanks for updating the tests.

Merged. Thanks for your contribution!

westonganger commented 3 years ago

v0.2.0 is now released which contains this fix.