workarea-commerce / workarea

Workarea is an enterprise-grade Ruby on Rails commerce platform
https://www.workarea.com
Other
326 stars 66 forks source link

Fix missing release changes for CSV importing with embedded models #485

Closed bencrouse closed 4 years ago

bencrouse commented 4 years ago

Trying to update an embedded model via CSV import with a release causes an existing changeset for the root model to get destroyed. This happens because the CSV import calls #save on the root, which has no changes so it removes the changeset.

This patch fixes by iterating over the models the CSV row might affect and calling #save on the embedded ones first (if necessary) to ensure the changesets get correctly created and to avoid calling the save on the root without changes which removes the existing changeset.