Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect
:skip
re: timestamp-only updates
When attributes are ignored, either by `:ignore` or by `:skip`, then during updates, timestamp attributes like `updated_at` should not be considered notable changes. [Fixes #569]
- Loading branch information
Showing
5 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'rails_helper' | ||
|
||
describe Skipper, :type => :model do | ||
describe "#update_attributes!", :versioning => true do | ||
context "updating a skipped attribute" do | ||
let(:t1) { Time.zone.local(2015, 7, 15, 20, 34, 0) } | ||
let(:t2) { Time.zone.local(2015, 7, 15, 20, 34, 30) } | ||
|
||
it "should not create a version" do | ||
skipper = Skipper.create!(:another_timestamp => t1) | ||
expect { | ||
skipper.update_attributes!(:another_timestamp => t2) | ||
}.to_not change { skipper.versions.length } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Skipper < ActiveRecord::Base | ||
has_paper_trail( | ||
:ignore => [:created_at], | ||
:skip => [:another_timestamp] | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters