mongoid / mongoid-history

Multi-user non-linear history tracking, auditing, undo, redo for mongoid.
https://rubygems.org/gems/mongoid-history
MIT License
393 stars 129 forks source link

Skip yielding when no block provided #213

Closed mikwat closed 6 years ago

mikwat commented 6 years ago

Normally track_history_for_action is always called with a block via around_create/update/destroy, but I've found in my own code base that there are times when it's desirable to call this method directly without a block.

Regardless, this change seems like good hygiene with little downside. If a block isn't provided, then there's no need to rescue and rollback the new history track.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.0004%) to 99.803% when pulling 500e7959be93d128e0a51fc3bd2139d46367da9a on skip-yield into e5a6f7777191b4353f4980ae78672ec039718490 on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.0004%) to 99.803% when pulling 17d3ba2a654bf33852ffd8e17c77a139585fc930 on skip-yield into e5a6f7777191b4353f4980ae78672ec039718490 on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.0004%) to 99.803% when pulling 17d3ba2a654bf33852ffd8e17c77a139585fc930 on skip-yield into e5a6f7777191b4353f4980ae78672ec039718490 on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.0004%) to 99.803% when pulling 17d3ba2a654bf33852ffd8e17c77a139585fc930 on skip-yield into e5a6f7777191b4353f4980ae78672ec039718490 on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.0004%) to 99.803% when pulling 6f49ae13a8ed0771b8c0fad7fd7357cad7f40526 on skip-yield into e5a6f7777191b4353f4980ae78672ec039718490 on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.0004%) to 99.803% when pulling 6f49ae13a8ed0771b8c0fad7fd7357cad7f40526 on skip-yield into e5a6f7777191b4353f4980ae78672ec039718490 on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.0004%) to 99.803% when pulling 6f49ae13a8ed0771b8c0fad7fd7357cad7f40526 on skip-yield into e5a6f7777191b4353f4980ae78672ec039718490 on master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.0004%) to 99.803% when pulling 6f49ae13a8ed0771b8c0fad7fd7357cad7f40526 on skip-yield into e5a6f7777191b4353f4980ae78672ec039718490 on master.

dblock commented 6 years ago

Since this is an interface change I would expect something to be updated in README, too.

mikwat commented 6 years ago

Thanks for the feedback @dblock I'm realizing the root problem appears to be that has_and_belongs_to_many relations may not be properly tracked. I'm going to close this PR and create a spec to explain what I'm seeing.