-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add spec to test embedded documents changes in parent's history #188
Add spec to test embedded documents changes in parent's history #188
Conversation
Here's an example of a CHANGELOG.md entry: * [#188](https://github.com/mongoid/mongoid-history/pull/188): Add spec to test embedded documents changes in parent's history - [@mpetazzoni](https://github.com/mpetazzoni). Generated by 🚫 danger |
This one failed because of rubocop, so |
2a4dfac
to
1f34a85
Compare
Running Anyway, running |
I played with this, and it's definitely a bug. In short, when the parent is saved, |
@mpetazzoni i appreciate the research done on this bug. I will try to look into the cause. |
Thanks @dblock and @jagdeepsingh, appreciated. Unfortunately I don't know enough about Rails and Mongoid to fix this myself; there's way too much magic going on and I couldn't figure out whether I was missing something in the way my models were setup, or if something was missing in mongoid-history's code. Looking forward to hearing back from you on this soon, hopefully with a fix😄 ! |
always returns nil when you update only the child. |
Yes, @mateuspontes as i posted here, this is because the |
@jagdeepsingh in create we track changes on embedded relations, can we use the same aproach to catch changes on update? |
* Fix test to check Parent and Child updates
I'll create a new PR with a new aproach to solve this without extra gems, this is working with embed_one only for now. It's a WIP [#<Tracker _id: 58efcf927ce04a71b049aac4, created_at: 2017-04-13 19:20:50 UTC, updated_at: 2017-04-13 19:20:50 UTC, association_chain: [{"name"=>"Parent", "id"=>BSON::ObjectId('58efcf927ce04a71b049aac5')}], modified: {"name"=>"bowser", "child"=>{"_id"=>BSON::ObjectId('58efcf927ce04a71b049aac6'), "name"=>"todd"}}, original: {}, version: 1, action: "create", scope: "parent", modifier_id: nil>, #<Tracker _id: 58efcf927ce04a71b049aac7, created_at: 2017-04-13 19:20:50 UTC, updated_at: 2017-04-13 19:20:50 UTC, association_chain: [{"name"=>"Parent", "id"=>BSON::ObjectId('58efcf927ce04a71b049aac5')}], modified: {"name"=>"brow"}, original: {"name"=>"bowser", "child"=>{}}, version: 2, action: "update", scope: "parent", modifier_id: nil>, #<Tracker _id: 58efcf927ce04a71b049aac8, created_at: 2017-04-13 19:20:50 UTC, updated_at: 2017-04-13 19:20:50 UTC, association_chain: [{"name"=>"Parent", "id"=>BSON::ObjectId('58efcf927ce04a71b049aac5')}], modified: {"child"=>{"name"=>"mario"}}, original: {"child"=>{"name"=>"todd"}}, version: 3, action: "update", scope: "parent", modifier_id: nil>] |
* Fix test to check Parent and Child updates Fix: remove focus: true and debug info with puts Fix tests: add method to track changes on update with changes * Add method to track changes with changes empty
* Fix test to check Parent and Child updates Fix: remove focus: true and debug info with puts Fix tests: add method to track changes on update with changes * Add method to track changes with changes empty
* Fix test to check Parent and Child updates Fix: remove focus: true and debug info with puts Fix tests: add method to track changes on update with changes * Add method to track changes with changes empty
* Fix test to check Parent and Child updates Fix: remove focus: true and debug info with puts Fix tests: add method to track changes on update with changes * Add method to track changes with changes empty
* Fix test to check Parent and Child updates Fix: remove focus: true and debug info with puts Fix tests: add method to track changes on update with changes * Add method to track changes with changes empty
Demonstrates #187.