forked from paper-trail-gem/paper_trail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
touch now always inserts null in object_changes
[Fixes paper-trail-gem#1121]
- Loading branch information
Showing
4 changed files
with
62 additions
and
4 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
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,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module PaperTrail | ||
module Events | ||
::RSpec.describe Update do | ||
describe "#data", versioning: true do | ||
context "is_touch false" do | ||
it "object_changes is present" do | ||
carter = Family::CelebrityFamily.create( | ||
name: "Carter", | ||
path_to_stardom: "Mexican radio" | ||
) | ||
carter.path_to_stardom = "Johnny" | ||
data = PaperTrail::Events::Update.new(carter, false, false, nil).data | ||
expect(data[:object_changes]).to eq( | ||
<<~YAML | ||
--- | ||
path_to_stardom: | ||
- Mexican radio | ||
- Johnny | ||
YAML | ||
) | ||
end | ||
end | ||
|
||
context "is_touch true" do | ||
it "object_changes is nil" do | ||
carter = Family::CelebrityFamily.create( | ||
name: "Carter", | ||
path_to_stardom: "Mexican radio" | ||
) | ||
carter.path_to_stardom = "Johnny" | ||
data = PaperTrail::Events::Update.new(carter, false, true, nil).data | ||
expect(data[:object_changes]).to be_nil | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |