This commit is contained in:
commit
16f4d3d196
|
@ -736,7 +736,7 @@ Remember to add those extra columns to your `versions` table and use `attr_acces
|
|||
|
||||
There are two scenarios: diffing adjacent versions and diffing non-adjacent versions.
|
||||
|
||||
The best way to diff adjacent versions is to get PaperTrail to do it for you. If you add an `object_changes` text column to your `versions` table, either at installation time with the `--with-changes` option or manually, PaperTrail will store the `changes` diff (excluding any attributes PaperTrail is ignoring) in each `update` version. You can use the `version.changeset` method to retrieve it. For example:
|
||||
The best way to diff adjacent versions is to get PaperTrail to do it for you. If you add an `object_changes` text column to your `versions` table, either at installation time with the `rails generate paper_trail:install --with-changes` option or manually, PaperTrail will store the `changes` diff (excluding any attributes PaperTrail is ignoring) in each `update` version. You can use the `version.changeset` method to retrieve it. For example:
|
||||
|
||||
```ruby
|
||||
>> widget = Widget.create :name => 'Bob'
|
||||
|
|
|
@ -4,14 +4,16 @@ describe "Articles" do
|
|||
let(:valid_params) { { :article => { :title => 'Doh', :content => Faker::Lorem.sentence } } }
|
||||
|
||||
context "versioning disabled" do
|
||||
specify { PaperTrail.enabled?.should be_false }
|
||||
specify { PaperTrail.should_not be_enabled }
|
||||
|
||||
it "should not create a version" do
|
||||
PaperTrail.should be_enabled_for_controller
|
||||
expect { post articles_path(valid_params) }.to_not change(PaperTrail::Version, :count)
|
||||
PaperTrail.should_not be_enabled_for_controller
|
||||
end
|
||||
|
||||
it "should not leak the state of the `PaperTrail.enabled_for_controlller?` into the next test" do
|
||||
PaperTrail.enabled_for_controller?.should be_true
|
||||
it "should not leak the state of the `PaperTrail.enabled_for_controller?` into the next test" do
|
||||
PaperTrail.should be_enabled_for_controller
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue