paper_trail 5.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cd678385e88cdbf152ecc4c2a4a1876afd7a175
4
- data.tar.gz: 93e28bbba83f8be22cfb8db3ee3e1912818f86af
3
+ metadata.gz: 83f408e34bbaf733c5fdab5ad37fc8c3718ab7ad
4
+ data.tar.gz: b1e73feb664e29d18946f3c526b1bb6b1ccec024
5
5
  SHA512:
6
- metadata.gz: 19a6e0288279964bced8ca4d4ae4ccacd668e1750dbff133d8c6e3ee76514c150402669c808954b24efcfb0fa085b370e3c20d2afe667bd4385d4ea233f4449e
7
- data.tar.gz: b26460e5948b60afb39fc6dc18c04f7c3337d449dc8a0401efc67d3cdabaa193fd3f23341d8d4f44f8ed726af4e5f81079d7be24372b3a6d8dbae683d852e44b
6
+ metadata.gz: b61edd25675bb0ea5254640920f04ff23aab1fc9dc729bc2bb27c5f4bd6774fb6e86df50d213d173a2892e7b2ef2e15240745e541d9f4fb0238c4b07574f6e56
7
+ data.tar.gz: 8b701f3921a8945fd3e7e55dbda82c7b716711e457f72caf7054dd502fd77a927ef5c5ebcf7d634f9c8465ba0bc8c44cc057220bea24cbaac1f5dbad7f2c9a96
@@ -96,7 +96,8 @@ DB=postgres bundle exec rake
96
96
  1. In the readme,
97
97
  - remove "unreleased" from the doc versions table
98
98
  - update any other references to version number
99
- 1. Commit and tag with `git tag -a -m "v5.0.0" "v5.0.0"`
99
+ 1. Commit
100
+ 1. Tag with `git tag -a -m "v5.0.0" "v5.0.0"`
100
101
  1. `git push --tags origin master`
101
102
  1. `gem build paper_trail.gemspec`
102
103
  1. `gem push paper_trail-5.0.0.gem`
@@ -8,6 +8,6 @@ Please use our template
8
8
  when reporting bugs.
9
9
 
10
10
  For other questions, please see our contributing guide.
11
- (https://github.com/airblade/paper_trail/blob/master/.github/CONTRIBUTING.MD)
11
+ (https://github.com/airblade/paper_trail/blob/master/.github/CONTRIBUTING.md)
12
12
 
13
13
  Thanks for your contribution!
@@ -8,7 +8,7 @@ Metrics/CyclomaticComplexity:
8
8
  Max: 13 # Goal: 6
9
9
 
10
10
  Metrics/ModuleLength:
11
- Max: 299
11
+ Max: 313
12
12
 
13
13
  Metrics/PerceivedComplexity:
14
14
  Max: 16 # Goal: 7
data/Appraisals CHANGED
@@ -2,7 +2,7 @@
2
2
  # `paper_trail.gemspec`.
3
3
  #
4
4
  # > The dependencies in your Appraisals file are combined with dependencies in
5
- # > your Gemfile, so you don"t need to repeat anything that"s the same for each
5
+ # > your Gemfile, so you don't need to repeat anything that's the same for each
6
6
  # > appraisal. If something is specified in both the Gemfile and an appraisal,
7
7
  # > the version from the appraisal takes precedence.
8
8
  # > https://github.com/thoughtbot/appraisal
@@ -26,15 +26,11 @@ appraise "ar4" do
26
26
  end
27
27
 
28
28
  appraise "ar5" do
29
- gem "activerecord", "5.0.0.beta1"
30
- gem "activemodel", "5.0.0.beta1"
31
- gem "actionpack", "5.0.0.beta1"
32
- gem "railties", "5.0.0.beta1"
33
- gem "rspec-rails", github: "rspec/rspec-rails"
34
- gem "rspec-core", github: "rspec/rspec-core"
35
- gem "rspec-expectations", github: "rspec/rspec-expectations"
36
- gem "rspec-mocks", github: "rspec/rspec-mocks"
37
- gem "rspec-support", github: "rspec/rspec-support"
29
+ gem "activerecord", "5.0.0.beta3"
30
+ gem "activemodel", "5.0.0.beta3"
31
+ gem "actionpack", "5.0.0.beta3"
32
+ gem "railties", "5.0.0.beta3"
33
+ gem "rspec-rails", "3.5.0.beta3"
38
34
  gem 'rails-controller-testing'
39
35
  # Sinatra stable conflicts with AR5's rack dependency
40
36
  gem 'sinatra', github: 'sinatra/sinatra'
@@ -1,3 +1,36 @@
1
+ ## 5.?.? (Unreleased)
2
+
3
+ ### Breaking Changes
4
+
5
+ - None
6
+
7
+ ### Added
8
+
9
+ - None
10
+
11
+ ### Fixed
12
+
13
+ - None
14
+
15
+ ## 5.1.0 (2016-05-20)
16
+
17
+ ### Breaking Changes
18
+
19
+ - None
20
+
21
+ ### Added
22
+
23
+ - [#809](https://github.com/airblade/paper_trail/pull/809) -
24
+ Print warning if version cannot be saved.
25
+
26
+ ### Fixed
27
+
28
+ - [#812](https://github.com/airblade/paper_trail/pull/812) -
29
+ Issue with saving HABTM associated objects using accepts_nested_attributes_for
30
+ - [#811](https://github.com/airblade/paper_trail/pull/811) -
31
+ Avoid unnecessary query in #record_destroy
32
+ - Improvements to documentation
33
+
1
34
  ## 5.0.1 (2016-05-04)
2
35
 
3
36
  ### Breaking Changes
data/README.md CHANGED
@@ -19,34 +19,39 @@ has been destroyed.
19
19
 
20
20
  ## Table of Contents
21
21
 
22
- - [Compatibility](#compatibility)
23
- - [Installation](#installation)
24
- - [Basic Usage](#basic-usage)
25
- - [API Summary](#api-summary)
26
- - Limiting What is Versioned, and When
27
- - [Choosing Lifecycle Events To Monitor](#choosing-lifecycle-events-to-monitor)
28
- - [Choosing When To Save New Versions](#choosing-when-to-save-new-versions)
29
- - [Choosing Attributes To Monitor](#choosing-attributes-to-monitor)
30
- - [Turning PaperTrail Off](#turning-papertrail-off)
31
- - [Limiting the Number of Versions Created](#limiting-the-number-of-versions-created)
32
- - Working With Versions
33
- - [Reverting And Undeleting A Model](#reverting-and-undeleting-a-model)
34
- - [Navigating Versions](#navigating-versions)
35
- - [Diffing Versions](#diffing-versions)
36
- - [Deleting Old Versions](#deleting-old-versions)
37
- - Saving More Information About Versions
38
- - [Finding Out Who Was Responsible For A Change](#finding-out-who-was-responsible-for-a-change)
39
- - [Associations](#associations)
40
- - [Storing metadata](#storing-metadata)
41
- - ActiveRecord
42
- - [Single Table Inheritance](#single-table-tnheritance)
43
- - Extensibility
44
- - [Custom Version Classes](#custom-version-classes)
45
- - [Custom Serializer](#custom-serializer)
46
- - [Testing](#testing)
47
- - [Sinatra](#sinatra)
48
-
49
- ## Compatibility
22
+ - [1. Introduction](#1-introduction)
23
+ - [1.a. Compatibility](#1a-compatibility)
24
+ - [1.b. Installation](#1b-installation)
25
+ - [1.c. Basic Usage](#1c-basic-usage)
26
+ - [1.d. API Summary](#1d-api-summary)
27
+ - [2. Limiting What is Versioned, and When](#2-limiting-what-is-versioned-and-when)
28
+ - [2.a. Choosing Lifecycle Events To Monitor](#2a-choosing-lifecycle-events-to-monitor)
29
+ - [2.b. Choosing When To Save New Versions](#2b-choosing-when-to-save-new-versions)
30
+ - [2.c. Choosing Attributes To Monitor](#2c-choosing-attributes-to-monitor)
31
+ - [2.d. Turning PaperTrail Off](#2d-turning-papertrail-off)
32
+ - [2.e. Limiting the Number of Versions Created](#2e-limiting-the-number-of-versions-created)
33
+ - [3. Working With Versions](#3-working-with-versions)
34
+ - [3.a. Reverting And Undeleting A Model](#3a-reverting-and-undeleting-a-model)
35
+ - [3.b. Navigating Versions](#3b-navigating-versions)
36
+ - [3.c. Diffing Versions](#3c-diffing-versions)
37
+ - [3.d. Deleting Old Versions](#3d-deleting-old-versions)
38
+ - [4. Saving More Information About Versions](#4-saving-more-information-about-versions)
39
+ - [4.a. Finding Out Who Was Responsible For A Change](#4a-finding-out-who-was-responsible-for-a-change)
40
+ - [4.b. Associations](#4b-associations)
41
+ - [4.c. Storing metadata](#4c-storing-metadata)
42
+ - [5. ActiveRecord](#5-activerecord)
43
+ - [5.a. Single Table Inheritance](#5a-single-table-inheritance-sti)
44
+ - [5.b. Configuring the `versions` Association](#5b-configuring-the-versions-association)
45
+ - [5.c. Generators](#5c-generators)
46
+ - [6. Extensibility](#6-extensibility)
47
+ - [6.a. Custom Version Classes](#6a-custom-version-classes)
48
+ - [6.b. Custom Serializer](#6b-custom-serializer)
49
+ - [7. Testing](#7-testing)
50
+ - [8. Sinatra](#8-sinatra)
51
+
52
+ ## 1. Introduction
53
+
54
+ ### 1.a. Compatibility
50
55
 
51
56
  | paper_trail | branch | tags | ruby | activerecord |
52
57
  | -------------- | ---------- | ------ | -------- | ------------ |
@@ -56,7 +61,7 @@ has been destroyed.
56
61
  | 2 | 2.7-stable | v2.x | >= 1.8.7 | >= 3.0, < 4 |
57
62
  | 1 | rails2 | v1.x | >= 1.8.7 | >= 2.3, < 3 |
58
63
 
59
- ## Installation
64
+ ### 1.b. Installation
60
65
 
61
66
  1. Add PaperTrail to your `Gemfile`.
62
67
 
@@ -70,7 +75,8 @@ has been destroyed.
70
75
  ```
71
76
 
72
77
  If using [rails_admin][38], you must enable the experimental
73
- [Associations](#associations) feature.
78
+ [Associations](#associations) feature. For more information on this
79
+ generator, see [section 5.c. Generators](#5c-generators).
74
80
 
75
81
  1. Add `has_paper_trail` to the models you want to track.
76
82
 
@@ -90,7 +96,7 @@ by adding a controller callback.
90
96
  end
91
97
  ```
92
98
 
93
- ## Basic Usage
99
+ ### 1.c. Basic Usage
94
100
 
95
101
  Your models now have a `versions` method which returns the "paper trail" of
96
102
  changes to your model.
@@ -146,7 +152,7 @@ Here's a helpful table showing what PaperTrail stores:
146
152
  PaperTrail stores the values in the Model Before column. Most other
147
153
  auditing/versioning plugins store the After column.
148
154
 
149
- ## API Summary
155
+ ### 1.d. API Summary
150
156
 
151
157
  When you declare `has_paper_trail` in your model, you get these methods:
152
158
 
@@ -156,7 +162,7 @@ class Widget < ActiveRecord::Base
156
162
  end
157
163
 
158
164
  # Returns this widget's versions. You can customise the name of the
159
- # association.
165
+ # association, but overriding this method is not supported.
160
166
  widget.versions
161
167
 
162
168
  # Return the version this widget was reified from, or nil if it is live.
@@ -226,13 +232,11 @@ version.index
226
232
  # Returns the event that caused this version (create|update|destroy).
227
233
  version.event
228
234
 
229
- # Query versions objects by attributes.
235
+ # Query the `versions.object` column (or `object_changes` column), by
236
+ # attributes, using the SQL LIKE operator. Known issue: inconsistent results for
237
+ # numeric values due to limitations of SQL wildcard matchers against the
238
+ # serialized objects.
230
239
  PaperTrail::Version.where_object(attr1: val1, attr2: val2)
231
-
232
- # Query versions object_changes field by attributes (requires
233
- # `object_changes` column on versions table).
234
- # Also can't guarantee consistent query results for numeric values
235
- # due to limitations of SQL wildcard matchers against the serialized objects.
236
240
  PaperTrail::Version.where_object_changes(attr1: val1)
237
241
  ```
238
242
 
@@ -248,7 +252,9 @@ user_for_paper_trail
248
252
  info_for_paper_trail
249
253
  ```
250
254
 
251
- ## Choosing Lifecycle Events To Monitor
255
+ ## 2. Limiting What is Versioned, and When
256
+
257
+ ### 2.a. Choosing Lifecycle Events To Monitor
252
258
 
253
259
  You can choose which events to track with the `on` option. For example, to
254
260
  ignore `create` events:
@@ -283,7 +289,7 @@ a.versions.size # 3
283
289
  a.versions.last.event # 'update'
284
290
  ```
285
291
 
286
- ### Controlling the Order of AR Callbacks
292
+ #### Controlling the Order of AR Callbacks
287
293
 
288
294
  The `has_paper_trail` method installs AR callbacks. If you need to control
289
295
  their order, use the `paper_trail_on_*` methods.
@@ -307,7 +313,7 @@ The `paper_trail_on_destroy` method can be further configured to happen
307
313
  `:after`. In PaperTrail 5, the default will be `:before`, to support
308
314
  ActiveRecord 5. (see https://github.com/airblade/paper_trail/pull/683)
309
315
 
310
- ## Choosing When To Save New Versions
316
+ ### 2.b. Choosing When To Save New Versions
311
317
 
312
318
  You can choose the conditions when to add new versions with the `if` and
313
319
  `unless` options. For example, to save versions only for US non-draft
@@ -320,13 +326,13 @@ class Translation < ActiveRecord::Base
320
326
  end
321
327
  ```
322
328
 
323
- ### Choosing Based on Changed Attributes
329
+ #### Choosing Based on Changed Attributes
324
330
 
325
331
  Starting with PaperTrail 4.0, versions are saved during an after-callback. If
326
332
  you decide whether to save a new version based on changed attributes, please
327
333
  use attribute_name_was instead of attribute_name.
328
334
 
329
- ## Choosing Attributes To Monitor
335
+ ### 2.c. Choosing Attributes To Monitor
330
336
 
331
337
  You can ignore changes to certain attributes like this:
332
338
 
@@ -413,11 +419,11 @@ class Article < ActiveRecord::Base
413
419
  end
414
420
  ```
415
421
 
416
- ## Turning PaperTrail Off
422
+ ### 2.d. Turning PaperTrail Off
417
423
 
418
424
  PaperTrail is on by default, but sometimes you don't want to record versions.
419
425
 
420
- ### Per Process
426
+ #### Per Process
421
427
 
422
428
  Turn PaperTrail off for all threads in a `ruby` process.
423
429
 
@@ -434,7 +440,7 @@ There is also a rails config option that does the same thing.
434
440
  config.paper_trail.enabled = false
435
441
  ```
436
442
 
437
- ### Per Request
443
+ #### Per Request
438
444
 
439
445
  Add a `paper_trail_enabled_for_controller` method to your controller.
440
446
 
@@ -446,14 +452,14 @@ class ApplicationController < ActionController::Base
446
452
  end
447
453
  ```
448
454
 
449
- ### Per Class
455
+ #### Per Class
450
456
 
451
457
  ```ruby
452
458
  Widget.paper_trail_off!
453
459
  Widget.paper_trail_on!
454
460
  ```
455
461
 
456
- ### Per Method
462
+ #### Per Method
457
463
 
458
464
  You can call a method without creating a new version using `without_versioning`.
459
465
  It takes either a method name as a symbol:
@@ -470,7 +476,7 @@ Or a block:
470
476
  end
471
477
  ```
472
478
 
473
- ## Limiting the Number of Versions Created
479
+ ### 2.e. Limiting the Number of Versions Created
474
480
 
475
481
  Configure `version_limit` to cap the number of versions saved per record. This
476
482
  does not apply to `create` events.
@@ -482,7 +488,9 @@ PaperTrail.config.version_limit = 3
482
488
  PaperTrail.config.version_limit = nil
483
489
  ```
484
490
 
485
- ## Reverting And Undeleting A Model
491
+ ## 3. Working With Versions
492
+
493
+ ### 3.a. Reverting And Undeleting A Model
486
494
 
487
495
  PaperTrail makes reverting to a previous version easy:
488
496
 
@@ -519,7 +527,7 @@ You could even use PaperTrail to implement an undo system, [Ryan Bates has!][3]
519
527
  If your model uses [optimistic locking][1] don't forget to [increment your
520
528
  `lock_version`][2] before saving or you'll get a `StaleObjectError`.
521
529
 
522
- ## Navigating Versions
530
+ ### 3.b. Navigating Versions
523
531
 
524
532
  You can call `previous_version` and `next_version` on an item to get it as it
525
533
  was/became. Note that these methods reify the item for you.
@@ -575,7 +583,7 @@ And you can perform `WHERE` queries for object versions based on attributes:
575
583
  PaperTrail::Version.where_object(content: "Hello", title: "Article")
576
584
  ```
577
585
 
578
- ## Diffing Versions
586
+ ### 3.c. Diffing Versions
579
587
 
580
588
  There are two scenarios: diffing adjacent versions and diffing non-adjacent
581
589
  versions.
@@ -640,7 +648,7 @@ If you wish to selectively record changes for some models but not others you
640
648
  can opt out of recording changes by passing `:save_changes => false` to your
641
649
  `has_paper_trail` method declaration.
642
650
 
643
- ## Deleting Old Versions
651
+ ### 3.d. Deleting Old Versions
644
652
 
645
653
  Over time your `versions` table will grow to an unwieldy size. Because each
646
654
  version is self-contained (see the Diffing section above for more) you can
@@ -654,7 +662,9 @@ sql> delete from versions where created_at < 2010-06-01;
654
662
  PaperTrail::Version.delete_all ["created_at < ?", 1.week.ago]
655
663
  ```
656
664
 
657
- ## Finding Out Who Was Responsible For A Change
665
+ ## 4. Saving More Information About Versions
666
+
667
+ ### 4.a. Finding Out Who Was Responsible For A Change
658
668
 
659
669
  Set `PaperTrail.whodunnit=`, and that value will be stored in the version's
660
670
  `whodunnit` column.
@@ -732,12 +742,12 @@ last_version.paper_trail_originator # 'Alice'
732
742
  last_version.terminator # 'Bob'
733
743
  ```
734
744
 
735
- ### Storing an ActiveRecord globalid in whodunnit
745
+ #### Storing an ActiveRecord globalid in whodunnit
736
746
 
737
747
  If you would like `whodunnit` to return an `ActiveRecord` object instead of a
738
748
  string, please try the [paper_trail-globalid][37] gem.
739
749
 
740
- ## Associations
750
+ ### 4.b. Associations
741
751
 
742
752
  **Experimental feature**, see caveats below.
743
753
 
@@ -843,7 +853,7 @@ widget.reload.wotsit # nil
843
853
  rails until ActiveRecord 4.2 (https://github.com/rails/rails/pull/14359).
844
854
  1. PaperTrail can't restore an association properly if the association record
845
855
  can be updated to replace its parent model (by replacing the foreign key)
846
- 1. Currently PaperTrail only support single `version_associations` table. The
856
+ 1. Currently PaperTrail only supports a single `version_associations` table. The
847
857
  implication is that you can only use a single table to store the versions for
848
858
  all related models. Sorry for those who use multiple version tables.
849
859
  1. PaperTrail only reifies the first level of associations, i.e., it does not
@@ -916,7 +926,7 @@ end
916
926
 
917
927
  See [issue 113][16] for a discussion about this.
918
928
 
919
- ## Storing Metadata
929
+ ### 4.c. Storing Metadata
920
930
 
921
931
  You can store arbitrary model-level metadata alongside each version like this:
922
932
 
@@ -936,7 +946,7 @@ PaperTrail will call your proc with the current article and store the result in
936
946
  the `author_id` column of the `versions` table.
937
947
  Don't forget to add any such columns to your `versions` table.
938
948
 
939
- ### Advantages of Metadata
949
+ #### Advantages of Metadata
940
950
 
941
951
  Why would you do this? In this example, `author_id` is an attribute of
942
952
  `Article` and PaperTrail will store it anyway in a serialized form in the
@@ -950,7 +960,7 @@ those versions you want:
950
960
  PaperTrail::Version.where(:author_id => author_id)
951
961
  ```
952
962
 
953
- ### Metadata from Controllers
963
+ #### Metadata from Controllers
954
964
 
955
965
  You can also store any information you like from your controller. Override
956
966
  the `info_for_paper_trail` method in your controller to return a hash whose keys
@@ -964,7 +974,7 @@ class ApplicationController
964
974
  end
965
975
  ```
966
976
 
967
- ### Protected Attributes and Metadata
977
+ #### Protected Attributes and Metadata
968
978
 
969
979
  If you are using rails 3 or the [protected_attributes][17] gem you must declare
970
980
  your metadata columns to be `attr_accessible`.
@@ -982,7 +992,9 @@ end
982
992
  If you're using [strong_parameters][18] instead of [protected_attributes][17]
983
993
  then there is no need to use `attr_accessible`.
984
994
 
985
- ## Single Table Inheritance (STI)
995
+ ## 5. ActiveRecord
996
+
997
+ ### 5.a. Single Table Inheritance (STI)
986
998
 
987
999
  PaperTrail supports [Single Table Inheritance][39], and even supports an
988
1000
  un-versioned base model, as of 23ffbdc7e1.
@@ -999,7 +1011,50 @@ end
999
1011
  However, there is a known issue when reifying [associations](#associations),
1000
1012
  see https://github.com/airblade/paper_trail/issues/594
1001
1013
 
1002
- ## Custom Version Classes
1014
+ ### 5.b. Configuring the `versions` Association
1015
+
1016
+ You may configure the name of the `versions` association by passing
1017
+ a different name to `has_paper_trail`.
1018
+
1019
+ ```ruby
1020
+ class Post < ActiveRecord::Base
1021
+ has_paper_trail class_name: 'Version', versions: :drafts
1022
+ end
1023
+
1024
+ Post.new.versions # => NoMethodError
1025
+ ```
1026
+
1027
+ Overriding (instead of configuring) the `versions` method is not supported.
1028
+ Overriding associations is not recommended in general.
1029
+
1030
+ ### 5.c. Generators
1031
+
1032
+ PaperTrail has one generator, `paper_trail:install`. It writes, but does not
1033
+ run, a migration file. This migration adds (at least) the `versions` table. The
1034
+ most up-to-date documentation for this generator can be found by running `rails
1035
+ generate paper_trail:install --help`, but a copy is included here for
1036
+ convenience.
1037
+
1038
+ ```
1039
+ Usage:
1040
+ rails generate paper_trail:install [options]
1041
+
1042
+ Options:
1043
+ [--with-changes], [--no-with-changes] # Store changeset (diff) with each version
1044
+ [--with-associations], [--no-with-associations] # Store transactional IDs to support association restoration
1045
+
1046
+ Runtime options:
1047
+ -f, [--force] # Overwrite files that already exist
1048
+ -p, [--pretend], [--no-pretend] # Run but do not make any changes
1049
+ -q, [--quiet], [--no-quiet] # Suppress status output
1050
+ -s, [--skip], [--no-skip] # Skip files that already exist
1051
+
1052
+ Generates (but does not run) a migration to add a versions table.
1053
+ ```
1054
+
1055
+ ## 6. Extensibility
1056
+
1057
+ ### 6.a. Custom Version Classes
1003
1058
 
1004
1059
  You can specify custom version subclasses with the `:class_name` option:
1005
1060
 
@@ -1016,13 +1071,13 @@ end
1016
1071
 
1017
1072
  Unlike ActiveRecord's `class_name`, you'll have to supply the complete module path to the class (e.g. `Foo::BarVersion` if your class is inside the module `Foo`).
1018
1073
 
1019
- ### Advantages
1074
+ #### Advantages
1020
1075
 
1021
1076
  1. For models which have a lot of versions, storing each model's versions in a
1022
1077
  separate table can improve the performance of certain database queries.
1023
1078
  1. Store different version [metadata](#storing-metadata) for different models.
1024
1079
 
1025
- ### Configuration
1080
+ #### Configuration
1026
1081
 
1027
1082
  If you are using Postgres, you should also define the sequence that your custom
1028
1083
  version class will use:
@@ -1068,7 +1123,7 @@ class Post < ActiveRecord::Base
1068
1123
  end
1069
1124
  ```
1070
1125
 
1071
- ## Custom Serializer
1126
+ ### 6.b. Custom Serializer
1072
1127
 
1073
1128
  By default, PaperTrail stores your changes as a `YAML` dump. You can override
1074
1129
  this with the serializer config option:
@@ -1083,7 +1138,7 @@ method. These serializers are included in the gem for your convenience:
1083
1138
  * [PaperTrail::Serializers::YAML][24] - Default
1084
1139
  * [PaperTrail::Serializers::JSON][25]
1085
1140
 
1086
- ### PostgreSQL JSON column type support
1141
+ #### PostgreSQL JSON column type support
1087
1142
 
1088
1143
  If you use PostgreSQL, and would like to store your `object` (and/or
1089
1144
  `object_changes`) data in a column of [type `json` or type `jsonb`][26], specify
@@ -1101,7 +1156,7 @@ end
1101
1156
  If you use the PostgreSQL `json` or `jsonb` column type, you do not need
1102
1157
  to specify a `PaperTrail.serializer`.
1103
1158
 
1104
- #### Convert existing YAML data to JSON
1159
+ ##### Convert existing YAML data to JSON
1105
1160
 
1106
1161
  If you've been using PaperTrail for a while with the default YAML serializer
1107
1162
  and you want to switch to JSON or JSONB, you're in a bit of a bind because
@@ -1153,7 +1208,7 @@ remove_column :versions, :old_object
1153
1208
  If you use the optional `object_changes` column, don't forget to convert it
1154
1209
  also, using the same technique.
1155
1210
 
1156
- #### Convert a Column from Text to JSON
1211
+ ##### Convert a Column from Text to JSON
1157
1212
 
1158
1213
  If your `object` column already contains JSON data, and you want to change its
1159
1214
  data type to `json` or `jsonb`, you can use the following [DDL][36]. Of course,
@@ -1182,12 +1237,12 @@ class ConvertVersionsObjectToJson < ActiveRecord::Migration
1182
1237
  end
1183
1238
  ```
1184
1239
 
1185
- ## Testing
1240
+ ## 7. Testing
1186
1241
 
1187
1242
  You may want to turn PaperTrail off to speed up your tests. See [Turning
1188
1243
  PaperTrail Off](#turning-papertrail-off) above.
1189
1244
 
1190
- ### Minitest
1245
+ ### 7.a. Minitest
1191
1246
 
1192
1247
  First, disable PT for the entire `ruby` process.
1193
1248
 
@@ -1227,7 +1282,7 @@ test "something that needs versioning" do
1227
1282
  end
1228
1283
  ```
1229
1284
 
1230
- ### RSpec
1285
+ ### 7.b. RSpec
1231
1286
 
1232
1287
  PaperTrail provides a helper, `paper_trail/frameworks/rspec.rb`, that works with
1233
1288
  [RSpec][27] to make it easier to control when `PaperTrail` is enabled during
@@ -1317,7 +1372,7 @@ matcher
1317
1372
 
1318
1373
  ```
1319
1374
 
1320
- ### Cucumber
1375
+ ### 7.c. Cucumber
1321
1376
 
1322
1377
  PaperTrail provides a helper for [Cucumber][28] that works similar to the RSpec
1323
1378
  helper.If you wish to use the helper, you will need to require in your cucumber
@@ -1350,7 +1405,7 @@ test to help prevent data spillover between tests. If you are using PaperTrail
1350
1405
  with Rails, the helper will automatically set the `PaperTrail.controller_info`
1351
1406
  value to `{}` as well, again, to help prevent data spillover between tests.
1352
1407
 
1353
- ### Spork
1408
+ ### 7.d. Spork
1354
1409
 
1355
1410
  If you wish to use the `RSpec` or `Cucumber` helpers with [Spork][29], you will
1356
1411
  need to manually require the helper(s) in your `prefork` block on your test
@@ -1373,7 +1428,7 @@ Spork.prefork do
1373
1428
  end
1374
1429
  ```
1375
1430
 
1376
- ### Zeus or Spring
1431
+ ### 7.e. Zeus or Spring
1377
1432
 
1378
1433
  If you wish to use the `RSpec` or `Cucumber` helpers with [Zeus][30] or
1379
1434
  [Spring][31], you will need to manually require the helper(s) in your test
@@ -1389,25 +1444,9 @@ require 'rspec/rails'
1389
1444
  require 'paper_trail/frameworks/rspec'
1390
1445
  ```
1391
1446
 
1392
- ## Testing PaperTrail
1393
-
1394
- Paper Trail has facilities to test against Postgres, Mysql and SQLite. To switch
1395
- between DB engines you will need to export the DB variable for the engine you
1396
- wish to test against.
1397
-
1398
- Though be aware we do not have the ability to create the db's (except sqlite) for
1399
- you. You can look at .travis.yml before_script for an example of how to create
1400
- the db's needed.
1401
-
1402
- ```
1403
- export DB=postgres
1404
- export DB=mysql
1405
- export DB=sqlite # this is default
1406
- ```
1407
-
1408
- ## Sinatra
1447
+ ## 8. Sinatra
1409
1448
 
1410
- In order to configure PaperTrail for usage with [Sinatra][12], your `Sinatra`
1449
+ To configure PaperTrail for usage with [Sinatra][12], your `Sinatra`
1411
1450
  app must be using `ActiveRecord` 3 or 4. It is also recommended to use the
1412
1451
  [Sinatra ActiveRecord Extension][13] or something similar for managing your
1413
1452
  applications `ActiveRecord` connection in a manner similar to the way `Rails`