mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
parent
534aa778fb
commit
6fd232df60
3 changed files with 10 additions and 2 deletions
|
@ -22,6 +22,8 @@
|
|||
|
||||
### Fixed
|
||||
|
||||
- [#715](https://github.com/airblade/paper_trail/issues/715) -
|
||||
Optimize post-rollback association reset.
|
||||
- [#701](https://github.com/airblade/paper_trail/pull/701) /
|
||||
[#699](https://github.com/airblade/paper_trail/issues/699) -
|
||||
Cleaning old versions explicitly preserves the most recent
|
||||
|
|
|
@ -195,9 +195,11 @@ module PaperTrail
|
|||
end
|
||||
|
||||
# Invoked after rollbacks to ensure versions records are not created
|
||||
# for changes that never actually took place
|
||||
# for changes that never actually took place.
|
||||
# Optimization: Use lazy `reset` instead of eager `reload` because, in
|
||||
# many use cases, the association will not be used.
|
||||
def clear_rolled_back_versions
|
||||
send(self.class.versions_association_name).reload
|
||||
send(self.class.versions_association_name).reset
|
||||
end
|
||||
|
||||
# Returns the object (not a Version) as it was at the given timestamp.
|
||||
|
|
|
@ -110,6 +110,10 @@ describe Widget, type: :model do
|
|||
expect(changeset.fetch("name", [])).to_not include(rolled_back_name)
|
||||
end
|
||||
end
|
||||
|
||||
it "has not yet loaded the assocation" do
|
||||
expect(widget.versions).to_not be_loaded
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue