paper_trail 4.2.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/{CONTRIBUTING.md → .github/CONTRIBUTING.md} +28 -9
 - data/.github/ISSUE_TEMPLATE.md +13 -0
 - data/.gitignore +2 -1
 - data/.rubocop.yml +100 -0
 - data/.rubocop_todo.yml +14 -0
 - data/.travis.yml +8 -9
 - data/Appraisals +41 -0
 - data/CHANGELOG.md +49 -9
 - data/Gemfile +1 -1
 - data/README.md +130 -109
 - data/Rakefile +19 -19
 - data/doc/bug_report_template.rb +20 -14
 - data/gemfiles/ar3.gemfile +10 -53
 - data/gemfiles/ar4.gemfile +7 -0
 - data/gemfiles/ar5.gemfile +13 -0
 - data/lib/generators/paper_trail/install_generator.rb +26 -18
 - data/lib/generators/paper_trail/templates/add_object_changes_to_versions.rb +4 -2
 - data/lib/generators/paper_trail/templates/add_transaction_id_column_to_versions.rb +2 -0
 - data/lib/generators/paper_trail/templates/create_version_associations.rb +9 -4
 - data/lib/generators/paper_trail/templates/create_versions.rb +39 -5
 - data/lib/paper_trail.rb +169 -146
 - data/lib/paper_trail/attributes_serialization.rb +89 -17
 - data/lib/paper_trail/cleaner.rb +15 -9
 - data/lib/paper_trail/config.rb +28 -11
 - data/lib/paper_trail/frameworks/active_record.rb +4 -0
 - data/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb +5 -1
 - data/lib/paper_trail/frameworks/active_record/models/paper_trail/version_association.rb +6 -2
 - data/lib/paper_trail/frameworks/cucumber.rb +1 -0
 - data/lib/paper_trail/frameworks/rails.rb +2 -7
 - data/lib/paper_trail/frameworks/rails/controller.rb +29 -9
 - data/lib/paper_trail/frameworks/rails/engine.rb +7 -1
 - data/lib/paper_trail/frameworks/rspec.rb +5 -5
 - data/lib/paper_trail/frameworks/rspec/helpers.rb +3 -1
 - data/lib/paper_trail/frameworks/sinatra.rb +6 -4
 - data/lib/paper_trail/has_paper_trail.rb +199 -106
 - data/lib/paper_trail/record_history.rb +1 -3
 - data/lib/paper_trail/reifier.rb +297 -118
 - data/lib/paper_trail/serializers/json.rb +3 -3
 - data/lib/paper_trail/serializers/yaml.rb +27 -8
 - data/lib/paper_trail/version_association_concern.rb +3 -1
 - data/lib/paper_trail/version_concern.rb +75 -35
 - data/lib/paper_trail/version_number.rb +6 -9
 - data/paper_trail.gemspec +44 -51
 - data/spec/generators/install_generator_spec.rb +24 -25
 - data/spec/generators/paper_trail/templates/create_versions_spec.rb +51 -0
 - data/spec/models/animal_spec.rb +12 -12
 - data/spec/models/boolit_spec.rb +8 -8
 - data/spec/models/callback_modifier_spec.rb +47 -47
 - data/spec/models/car_spec.rb +13 -0
 - data/spec/models/fluxor_spec.rb +3 -3
 - data/spec/models/gadget_spec.rb +19 -19
 - data/spec/models/joined_version_spec.rb +3 -3
 - data/spec/models/json_version_spec.rb +23 -24
 - data/spec/models/kitchen/banana_spec.rb +3 -3
 - data/spec/models/not_on_update_spec.rb +7 -4
 - data/spec/models/post_with_status_spec.rb +13 -3
 - data/spec/models/skipper_spec.rb +10 -10
 - data/spec/models/thing_spec.rb +4 -4
 - data/spec/models/truck_spec.rb +5 -0
 - data/spec/models/vehicle_spec.rb +5 -0
 - data/spec/models/version_spec.rb +103 -59
 - data/spec/models/widget_spec.rb +82 -52
 - data/spec/modules/paper_trail_spec.rb +2 -2
 - data/spec/modules/version_concern_spec.rb +11 -12
 - data/spec/modules/version_number_spec.rb +2 -4
 - data/spec/paper_trail/config_spec.rb +10 -29
 - data/spec/paper_trail_spec.rb +16 -14
 - data/spec/rails_helper.rb +10 -9
 - data/spec/requests/articles_spec.rb +11 -7
 - data/spec/spec_helper.rb +41 -22
 - data/spec/support/alt_db_init.rb +8 -13
 - data/test/custom_json_serializer.rb +3 -3
 - data/test/dummy/Rakefile +2 -2
 - data/test/dummy/app/controllers/application_controller.rb +21 -8
 - data/test/dummy/app/controllers/articles_controller.rb +11 -8
 - data/test/dummy/app/controllers/widgets_controller.rb +13 -12
 - data/test/dummy/app/models/animal.rb +1 -1
 - data/test/dummy/app/models/article.rb +19 -11
 - data/test/dummy/app/models/authorship.rb +1 -1
 - data/test/dummy/app/models/bar_habtm.rb +4 -0
 - data/test/dummy/app/models/book.rb +4 -4
 - data/test/dummy/app/models/boolit.rb +1 -1
 - data/test/dummy/app/models/callback_modifier.rb +6 -6
 - data/test/dummy/app/models/car.rb +3 -0
 - data/test/dummy/app/models/chapter.rb +4 -4
 - data/test/dummy/app/models/customer.rb +1 -1
 - data/test/dummy/app/models/document.rb +2 -2
 - data/test/dummy/app/models/editor.rb +1 -1
 - data/test/dummy/app/models/foo_habtm.rb +4 -0
 - data/test/dummy/app/models/fruit.rb +2 -2
 - data/test/dummy/app/models/gadget.rb +1 -1
 - data/test/dummy/app/models/kitchen/banana.rb +1 -1
 - data/test/dummy/app/models/legacy_widget.rb +2 -2
 - data/test/dummy/app/models/line_item.rb +1 -1
 - data/test/dummy/app/models/not_on_update.rb +1 -1
 - data/test/dummy/app/models/person.rb +6 -6
 - data/test/dummy/app/models/post.rb +1 -1
 - data/test/dummy/app/models/post_with_status.rb +1 -1
 - data/test/dummy/app/models/quotation.rb +1 -1
 - data/test/dummy/app/models/section.rb +1 -1
 - data/test/dummy/app/models/skipper.rb +2 -2
 - data/test/dummy/app/models/song.rb +13 -4
 - data/test/dummy/app/models/thing.rb +2 -2
 - data/test/dummy/app/models/translation.rb +2 -2
 - data/test/dummy/app/models/truck.rb +4 -0
 - data/test/dummy/app/models/vehicle.rb +4 -0
 - data/test/dummy/app/models/whatchamajigger.rb +1 -1
 - data/test/dummy/app/models/widget.rb +7 -6
 - data/test/dummy/app/versions/joined_version.rb +4 -3
 - data/test/dummy/app/versions/json_version.rb +1 -1
 - data/test/dummy/app/versions/kitchen/banana_version.rb +1 -1
 - data/test/dummy/app/versions/post_version.rb +2 -2
 - data/test/dummy/config.ru +1 -1
 - data/test/dummy/config/application.rb +20 -9
 - data/test/dummy/config/boot.rb +5 -5
 - data/test/dummy/config/environment.rb +1 -1
 - data/test/dummy/config/environments/development.rb +4 -3
 - data/test/dummy/config/environments/production.rb +3 -2
 - data/test/dummy/config/environments/test.rb +15 -5
 - data/test/dummy/config/initializers/backtrace_silencers.rb +4 -2
 - data/test/dummy/config/initializers/paper_trail.rb +1 -2
 - data/test/dummy/config/initializers/secret_token.rb +3 -1
 - data/test/dummy/config/initializers/session_store.rb +1 -1
 - data/test/dummy/config/routes.rb +2 -2
 - data/test/dummy/db/migrate/20110208155312_set_up_test_tables.rb +120 -74
 - data/test/dummy/db/schema.rb +29 -6
 - data/test/dummy/script/rails +6 -4
 - data/test/functional/controller_test.rb +34 -35
 - data/test/functional/enabled_for_controller_test.rb +6 -7
 - data/test/functional/modular_sinatra_test.rb +43 -38
 - data/test/functional/sinatra_test.rb +49 -40
 - data/test/functional/thread_safety_test.rb +4 -6
 - data/test/paper_trail_test.rb +15 -14
 - data/test/test_helper.rb +68 -44
 - data/test/time_travel_helper.rb +1 -15
 - data/test/unit/associations_test.rb +517 -251
 - data/test/unit/cleaner_test.rb +66 -60
 - data/test/unit/inheritance_column_test.rb +17 -17
 - data/test/unit/model_test.rb +611 -504
 - data/test/unit/protected_attrs_test.rb +16 -12
 - data/test/unit/serializer_test.rb +44 -43
 - data/test/unit/serializers/json_test.rb +17 -18
 - data/test/unit/serializers/mixin_json_test.rb +15 -14
 - data/test/unit/serializers/mixin_yaml_test.rb +20 -16
 - data/test/unit/serializers/yaml_test.rb +12 -13
 - data/test/unit/timestamp_test.rb +10 -12
 - data/test/unit/version_test.rb +7 -7
 - metadata +92 -40
 
    
        data/spec/models/widget_spec.rb
    CHANGED
    
    | 
         @@ -1,55 +1,58 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "rails_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            describe Widget, : 
     | 
| 
       4 
     | 
    
         
            -
              describe  
     | 
| 
      
 3 
     | 
    
         
            +
            describe Widget, type: :model do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "`be_versioned` matcher" do
         
     | 
| 
       5 
5 
     | 
    
         
             
                it { is_expected.to be_versioned }
         
     | 
| 
       6 
6 
     | 
    
         
             
              end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
              let(:widget) { Widget.create! : 
     | 
| 
      
 8 
     | 
    
         
            +
              let(:widget) { Widget.create! name: "Bob", an_integer: 1 }
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
              describe  
     | 
| 
      
 10 
     | 
    
         
            +
              describe "`have_a_version_with` matcher", versioning: true do
         
     | 
| 
       11 
11 
     | 
    
         
             
                before do
         
     | 
| 
       12 
     | 
    
         
            -
                  widget.update_attributes!(: 
     | 
| 
       13 
     | 
    
         
            -
                  widget.update_attributes!(: 
     | 
| 
       14 
     | 
    
         
            -
                  widget.update_attributes!(: 
     | 
| 
      
 12 
     | 
    
         
            +
                  widget.update_attributes!(name: "Leonard", an_integer: 1)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  widget.update_attributes!(name: "Tom")
         
     | 
| 
      
 14 
     | 
    
         
            +
                  widget.update_attributes!(name: "Bob")
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                it "is possible to do assertions on versions" do
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
                  expect(widget).to have_a_version_with name: "Leonard", an_integer: 1
         
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(widget).to have_a_version_with an_integer: 1
         
     | 
| 
      
 20 
     | 
    
         
            +
                  expect(widget).to have_a_version_with name: "Tom"
         
     | 
| 
       21 
21 
     | 
    
         
             
                end
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
              describe " 
     | 
| 
       25 
     | 
    
         
            -
                context  
     | 
| 
       26 
     | 
    
         
            -
                  it  
     | 
| 
      
 24 
     | 
    
         
            +
              describe "versioning option" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                context "enabled", versioning: true do
         
     | 
| 
      
 26 
     | 
    
         
            +
                  it "should enable versioning" do
         
     | 
| 
       27 
27 
     | 
    
         
             
                    expect(widget.versions.size).to eq(1)
         
     | 
| 
       28 
28 
     | 
    
         
             
                  end
         
     | 
| 
       29 
29 
     | 
    
         
             
                end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                context  
     | 
| 
       32 
     | 
    
         
            -
                  it  
     | 
| 
      
 31 
     | 
    
         
            +
                context "disabled (default)" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                  it "should not enable versioning" do
         
     | 
| 
       33 
33 
     | 
    
         
             
                    expect(widget.versions.size).to eq(0)
         
     | 
| 
       34 
34 
     | 
    
         
             
                  end
         
     | 
| 
       35 
35 
     | 
    
         
             
                end
         
     | 
| 
       36 
36 
     | 
    
         
             
              end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
              describe "Callbacks", : 
     | 
| 
      
 38 
     | 
    
         
            +
              describe "Callbacks", versioning: true do
         
     | 
| 
       39 
39 
     | 
    
         
             
                describe :before_save do
         
     | 
| 
       40 
     | 
    
         
            -
                  context  
     | 
| 
       41 
     | 
    
         
            -
                    before { widget.update_attributes!(: 
     | 
| 
      
 40 
     | 
    
         
            +
                  context ":on => :update" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                    before { widget.update_attributes!(name: "Foobar") }
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
                    subject { widget.versions.last.reify }
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
                    it " 
     | 
| 
       46 
     | 
    
         
            -
                       
     | 
| 
      
 45 
     | 
    
         
            +
                    it "resets value for timestamp attrs for update so that value gets updated properly" do
         
     | 
| 
      
 46 
     | 
    
         
            +
                      # Travel 1 second because MySQL lacks sub-second resolution
         
     | 
| 
      
 47 
     | 
    
         
            +
                      Timecop.travel(1) do
         
     | 
| 
      
 48 
     | 
    
         
            +
                        expect { subject.save! }.to change(subject, :updated_at)
         
     | 
| 
      
 49 
     | 
    
         
            +
                      end
         
     | 
| 
       47 
50 
     | 
    
         
             
                    end
         
     | 
| 
       48 
51 
     | 
    
         
             
                  end
         
     | 
| 
       49 
52 
     | 
    
         
             
                end
         
     | 
| 
       50 
53 
     | 
    
         | 
| 
       51 
54 
     | 
    
         
             
                describe :after_create do
         
     | 
| 
       52 
     | 
    
         
            -
                  let(:widget) { Widget.create!(: 
     | 
| 
      
 55 
     | 
    
         
            +
                  let(:widget) { Widget.create!(name: "Foobar", created_at: Time.now - 1.week) }
         
     | 
| 
       53 
56 
     | 
    
         | 
| 
       54 
57 
     | 
    
         
             
                  it "corresponding version should use the widget's `updated_at`" do
         
     | 
| 
       55 
58 
     | 
    
         
             
                    expect(widget.versions.last.created_at.to_i).to eq(widget.updated_at.to_i)
         
     | 
| 
         @@ -57,7 +60,7 @@ describe Widget, :type => :model do 
     | 
|
| 
       57 
60 
     | 
    
         
             
                end
         
     | 
| 
       58 
61 
     | 
    
         | 
| 
       59 
62 
     | 
    
         
             
                describe :after_update do
         
     | 
| 
       60 
     | 
    
         
            -
                  before { widget.update_attributes!(: 
     | 
| 
      
 63 
     | 
    
         
            +
                  before { widget.update_attributes!(name: "Foobar", updated_at: Time.now + 1.week) }
         
     | 
| 
       61 
64 
     | 
    
         | 
| 
       62 
65 
     | 
    
         
             
                  subject { widget.versions.last.reify }
         
     | 
| 
       63 
66 
     | 
    
         | 
| 
         @@ -87,13 +90,13 @@ describe Widget, :type => :model do 
     | 
|
| 
       87 
90 
     | 
    
         
             
                end
         
     | 
| 
       88 
91 
     | 
    
         | 
| 
       89 
92 
     | 
    
         
             
                describe :after_rollback do
         
     | 
| 
       90 
     | 
    
         
            -
                  let(:rolled_back_name) {  
     | 
| 
      
 93 
     | 
    
         
            +
                  let(:rolled_back_name) { "Big Moo" }
         
     | 
| 
       91 
94 
     | 
    
         | 
| 
       92 
95 
     | 
    
         
             
                  before do
         
     | 
| 
       93 
96 
     | 
    
         
             
                    begin
         
     | 
| 
       94 
97 
     | 
    
         
             
                      widget.transaction do
         
     | 
| 
       95 
     | 
    
         
            -
                        widget.update_attributes!(: 
     | 
| 
       96 
     | 
    
         
            -
                        widget.update_attributes!(: 
     | 
| 
      
 98 
     | 
    
         
            +
                        widget.update_attributes!(name: rolled_back_name)
         
     | 
| 
      
 99 
     | 
    
         
            +
                        widget.update_attributes!(name: Widget::EXCLUDED_NAME)
         
     | 
| 
       97 
100 
     | 
    
         
             
                      end
         
     | 
| 
       98 
101 
     | 
    
         
             
                    rescue ActiveRecord::RecordInvalid
         
     | 
| 
       99 
102 
     | 
    
         
             
                      widget.reload
         
     | 
| 
         @@ -102,15 +105,19 @@ describe Widget, :type => :model do 
     | 
|
| 
       102 
105 
     | 
    
         
             
                    end
         
     | 
| 
       103 
106 
     | 
    
         
             
                  end
         
     | 
| 
       104 
107 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
                  it  
     | 
| 
      
 108 
     | 
    
         
            +
                  it "does not create an event for changes that did not happen" do
         
     | 
| 
       106 
109 
     | 
    
         
             
                    widget.versions.map(&:changeset).each do |changeset|
         
     | 
| 
       107 
     | 
    
         
            -
                      expect(changeset.fetch( 
     | 
| 
      
 110 
     | 
    
         
            +
                      expect(changeset.fetch("name", [])).to_not include(rolled_back_name)
         
     | 
| 
       108 
111 
     | 
    
         
             
                    end
         
     | 
| 
       109 
112 
     | 
    
         
             
                  end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                  it "has not yet loaded the assocation" do
         
     | 
| 
      
 115 
     | 
    
         
            +
                    expect(widget.versions).to_not be_loaded
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
       110 
117 
     | 
    
         
             
                end
         
     | 
| 
       111 
118 
     | 
    
         
             
              end
         
     | 
| 
       112 
119 
     | 
    
         | 
| 
       113 
     | 
    
         
            -
              describe "Association", : 
     | 
| 
      
 120 
     | 
    
         
            +
              describe "Association", versioning: true do
         
     | 
| 
       114 
121 
     | 
    
         
             
                describe "sort order" do
         
     | 
| 
       115 
122 
     | 
    
         
             
                  it "should sort by the timestamp order from the `VersionConcern`" do
         
     | 
| 
       116 
123 
     | 
    
         
             
                    expect(widget.versions.to_sql).to eq(
         
     | 
| 
         @@ -119,14 +126,25 @@ describe Widget, :type => :model do 
     | 
|
| 
       119 
126 
     | 
    
         
             
                end
         
     | 
| 
       120 
127 
     | 
    
         
             
              end
         
     | 
| 
       121 
128 
     | 
    
         | 
| 
      
 129 
     | 
    
         
            +
              if defined?(ActiveRecord::IdentityMap) && ActiveRecord::IdentityMap.respond_to?(:without)
         
     | 
| 
      
 130 
     | 
    
         
            +
                describe "IdentityMap", versioning: true do
         
     | 
| 
      
 131 
     | 
    
         
            +
                  it "should not clobber the IdentityMap when reifying" do
         
     | 
| 
      
 132 
     | 
    
         
            +
                    widget.update_attributes name: "Henry", created_at: Time.now - 1.day
         
     | 
| 
      
 133 
     | 
    
         
            +
                    widget.update_attributes name: "Harry"
         
     | 
| 
      
 134 
     | 
    
         
            +
                    expect(ActiveRecord::IdentityMap).to receive(:without).once
         
     | 
| 
      
 135 
     | 
    
         
            +
                    widget.versions.last.reify
         
     | 
| 
      
 136 
     | 
    
         
            +
                  end
         
     | 
| 
      
 137 
     | 
    
         
            +
                end
         
     | 
| 
      
 138 
     | 
    
         
            +
              end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
       122 
140 
     | 
    
         
             
              describe "Methods" do
         
     | 
| 
       123 
     | 
    
         
            -
                describe "Instance", : 
     | 
| 
      
 141 
     | 
    
         
            +
                describe "Instance", versioning: true do
         
     | 
| 
       124 
142 
     | 
    
         
             
                  describe '#paper_trail_originator' do
         
     | 
| 
       125 
143 
     | 
    
         
             
                    it { is_expected.to respond_to(:paper_trail_originator) }
         
     | 
| 
       126 
144 
     | 
    
         | 
| 
       127 
145 
     | 
    
         
             
                    describe "return value" do
         
     | 
| 
       128 
     | 
    
         
            -
                      let(:orig_name) {  
     | 
| 
       129 
     | 
    
         
            -
                      let(:new_name) {  
     | 
| 
      
 146 
     | 
    
         
            +
                      let(:orig_name) { FFaker::Name.name }
         
     | 
| 
      
 147 
     | 
    
         
            +
                      let(:new_name) { FFaker::Name.name }
         
     | 
| 
       130 
148 
     | 
    
         
             
                      before { PaperTrail.whodunnit = orig_name }
         
     | 
| 
       131 
149 
     | 
    
         | 
| 
       132 
150 
     | 
    
         
             
                      context "accessed from live model instance" do
         
     | 
| 
         @@ -134,16 +152,16 @@ describe Widget, :type => :model do 
     | 
|
| 
       134 
152 
     | 
    
         | 
| 
       135 
153 
     | 
    
         
             
                        it "should return the originator for the model at a given state" do
         
     | 
| 
       136 
154 
     | 
    
         
             
                          expect(widget.paper_trail_originator).to eq(orig_name)
         
     | 
| 
       137 
     | 
    
         
            -
                          widget.whodunnit(new_name) { |w| w.update_attributes(: 
     | 
| 
      
 155 
     | 
    
         
            +
                          widget.whodunnit(new_name) { |w| w.update_attributes(name: "Elizabeth") }
         
     | 
| 
       138 
156 
     | 
    
         
             
                          expect(widget.paper_trail_originator).to eq(new_name)
         
     | 
| 
       139 
157 
     | 
    
         
             
                        end
         
     | 
| 
       140 
158 
     | 
    
         
             
                      end
         
     | 
| 
       141 
159 
     | 
    
         | 
| 
       142 
160 
     | 
    
         
             
                      context "accessed from a reified model instance" do
         
     | 
| 
       143 
161 
     | 
    
         
             
                        before do
         
     | 
| 
       144 
     | 
    
         
            -
                          widget.update_attributes(: 
     | 
| 
      
 162 
     | 
    
         
            +
                          widget.update_attributes(name: "Andy")
         
     | 
| 
       145 
163 
     | 
    
         
             
                          PaperTrail.whodunnit = new_name
         
     | 
| 
       146 
     | 
    
         
            -
                          widget.update_attributes(: 
     | 
| 
      
 164 
     | 
    
         
            +
                          widget.update_attributes(name: "Elizabeth")
         
     | 
| 
       147 
165 
     | 
    
         
             
                        end
         
     | 
| 
       148 
166 
     | 
    
         | 
| 
       149 
167 
     | 
    
         
             
                        context "default behavior (no `options[:dup]` option passed in)" do
         
     | 
| 
         @@ -159,7 +177,7 @@ describe Widget, :type => :model do 
     | 
|
| 
       159 
177 
     | 
    
         
             
                        end
         
     | 
| 
       160 
178 
     | 
    
         | 
| 
       161 
179 
     | 
    
         
             
                        context "creating a new instance (`options[:dup] == true`)" do
         
     | 
| 
       162 
     | 
    
         
            -
                          let(:reified_widget) { widget.versions[1].reify(: 
     | 
| 
      
 180 
     | 
    
         
            +
                          let(:reified_widget) { widget.versions[1].reify(dup: true) }
         
     | 
| 
       163 
181 
     | 
    
         | 
| 
       164 
182 
     | 
    
         
             
                          it "should return the appropriate originator" do
         
     | 
| 
       165 
183 
     | 
    
         
             
                            expect(reified_widget.paper_trail_originator).to eq(orig_name)
         
     | 
| 
         @@ -178,13 +196,13 @@ describe Widget, :type => :model do 
     | 
|
| 
       178 
196 
     | 
    
         | 
| 
       179 
197 
     | 
    
         
             
                    it { is_expected.to respond_to(:originator) }
         
     | 
| 
       180 
198 
     | 
    
         | 
| 
       181 
     | 
    
         
            -
                    it  
     | 
| 
      
 199 
     | 
    
         
            +
                    it "should set the invoke `paper_trail_originator`" do
         
     | 
| 
       182 
200 
     | 
    
         
             
                      allow(::ActiveSupport::Deprecation).to receive(:warn)
         
     | 
| 
       183 
201 
     | 
    
         
             
                      is_expected.to receive(:paper_trail_originator)
         
     | 
| 
       184 
202 
     | 
    
         
             
                      subject.originator
         
     | 
| 
       185 
203 
     | 
    
         
             
                    end
         
     | 
| 
       186 
204 
     | 
    
         | 
| 
       187 
     | 
    
         
            -
                    it  
     | 
| 
      
 205 
     | 
    
         
            +
                    it "should display a deprecation warning" do
         
     | 
| 
       188 
206 
     | 
    
         
             
                      expect(::ActiveSupport::Deprecation).to receive(:warn).
         
     | 
| 
       189 
207 
     | 
    
         
             
                        with(/Use paper_trail_originator instead of originator/)
         
     | 
| 
       190 
208 
     | 
    
         
             
                      subject.originator
         
     | 
| 
         @@ -196,7 +214,7 @@ describe Widget, :type => :model do 
     | 
|
| 
       196 
214 
     | 
    
         | 
| 
       197 
215 
     | 
    
         
             
                    context "Timestamp argument is AFTER object has been destroyed" do
         
     | 
| 
       198 
216 
     | 
    
         
             
                      before do
         
     | 
| 
       199 
     | 
    
         
            -
                        widget.update_attribute(:name,  
     | 
| 
      
 217 
     | 
    
         
            +
                        widget.update_attribute(:name, "foobar")
         
     | 
| 
       200 
218 
     | 
    
         
             
                        widget.destroy
         
     | 
| 
       201 
219 
     | 
    
         
             
                      end
         
     | 
| 
       202 
220 
     | 
    
         | 
| 
         @@ -211,13 +229,15 @@ describe Widget, :type => :model do 
     | 
|
| 
       211 
229 
     | 
    
         | 
| 
       212 
230 
     | 
    
         
             
                    context "no block given" do
         
     | 
| 
       213 
231 
     | 
    
         
             
                      it "should raise an error" do
         
     | 
| 
       214 
     | 
    
         
            -
                        expect { 
     | 
| 
      
 232 
     | 
    
         
            +
                        expect {
         
     | 
| 
      
 233 
     | 
    
         
            +
                          widget.whodunnit("Ben")
         
     | 
| 
      
 234 
     | 
    
         
            +
                        }.to raise_error(ArgumentError, "expected to receive a block")
         
     | 
| 
       215 
235 
     | 
    
         
             
                      end
         
     | 
| 
       216 
236 
     | 
    
         
             
                    end
         
     | 
| 
       217 
237 
     | 
    
         | 
| 
       218 
238 
     | 
    
         
             
                    context "block given" do
         
     | 
| 
       219 
     | 
    
         
            -
                      let(:orig_name) {  
     | 
| 
       220 
     | 
    
         
            -
                      let(:new_name) {  
     | 
| 
      
 239 
     | 
    
         
            +
                      let(:orig_name) { FFaker::Name.name }
         
     | 
| 
      
 240 
     | 
    
         
            +
                      let(:new_name) { FFaker::Name.name }
         
     | 
| 
       221 
241 
     | 
    
         | 
| 
       222 
242 
     | 
    
         
             
                      before do
         
     | 
| 
       223 
243 
     | 
    
         
             
                        PaperTrail.whodunnit = orig_name
         
     | 
| 
         @@ -227,19 +247,23 @@ describe Widget, :type => :model do 
     | 
|
| 
       227 
247 
     | 
    
         
             
                      it "should modify value of `PaperTrail.whodunnit` while executing the block" do
         
     | 
| 
       228 
248 
     | 
    
         
             
                        widget.whodunnit(new_name) do
         
     | 
| 
       229 
249 
     | 
    
         
             
                          expect(PaperTrail.whodunnit).to eq(new_name)
         
     | 
| 
       230 
     | 
    
         
            -
                          widget.update_attributes(: 
     | 
| 
      
 250 
     | 
    
         
            +
                          widget.update_attributes(name: "Elizabeth")
         
     | 
| 
       231 
251 
     | 
    
         
             
                        end
         
     | 
| 
       232 
252 
     | 
    
         
             
                        expect(widget.versions.last.whodunnit).to eq(new_name)
         
     | 
| 
       233 
253 
     | 
    
         
             
                      end
         
     | 
| 
       234 
254 
     | 
    
         | 
| 
       235 
     | 
    
         
            -
                       
     | 
| 
       236 
     | 
    
         
            -
                         
     | 
| 
       237 
     | 
    
         
            -
             
     | 
| 
      
 255 
     | 
    
         
            +
                      context "after executing the block" do
         
     | 
| 
      
 256 
     | 
    
         
            +
                        it "reverts value of whodunnit to previous value" do
         
     | 
| 
      
 257 
     | 
    
         
            +
                          widget.whodunnit(new_name) { |w| w.update_attributes(name: "Elizabeth") }
         
     | 
| 
      
 258 
     | 
    
         
            +
                          expect(PaperTrail.whodunnit).to eq(orig_name)
         
     | 
| 
      
 259 
     | 
    
         
            +
                        end
         
     | 
| 
       238 
260 
     | 
    
         
             
                      end
         
     | 
| 
       239 
261 
     | 
    
         | 
| 
       240 
262 
     | 
    
         
             
                      context "error within block" do
         
     | 
| 
       241 
     | 
    
         
            -
                        it " 
     | 
| 
       242 
     | 
    
         
            -
                          expect { 
     | 
| 
      
 263 
     | 
    
         
            +
                        it "still reverts the whodunnit value to previous value" do
         
     | 
| 
      
 264 
     | 
    
         
            +
                          expect {
         
     | 
| 
      
 265 
     | 
    
         
            +
                            widget.whodunnit(new_name) { raise }
         
     | 
| 
      
 266 
     | 
    
         
            +
                          }.to raise_error(RuntimeError)
         
     | 
| 
       243 
267 
     | 
    
         
             
                          expect(PaperTrail.whodunnit).to eq(orig_name)
         
     | 
| 
       244 
268 
     | 
    
         
             
                        end
         
     | 
| 
       245 
269 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -251,13 +275,19 @@ describe Widget, :type => :model do 
     | 
|
| 
       251 
275 
     | 
    
         | 
| 
       252 
276 
     | 
    
         
             
                    it "creates a version" do
         
     | 
| 
       253 
277 
     | 
    
         
             
                      count = widget.versions.size
         
     | 
| 
       254 
     | 
    
         
            -
                       
     | 
| 
      
 278 
     | 
    
         
            +
                      # Travel 1 second because MySQL lacks sub-second resolution
         
     | 
| 
      
 279 
     | 
    
         
            +
                      Timecop.travel(1) do
         
     | 
| 
      
 280 
     | 
    
         
            +
                        widget.touch_with_version
         
     | 
| 
      
 281 
     | 
    
         
            +
                      end
         
     | 
| 
       255 
282 
     | 
    
         
             
                      expect(widget.versions.size).to eq(count + 1)
         
     | 
| 
       256 
283 
     | 
    
         
             
                    end
         
     | 
| 
       257 
284 
     | 
    
         | 
| 
       258 
285 
     | 
    
         
             
                    it "increments the `:updated_at` timestamp" do
         
     | 
| 
       259 
286 
     | 
    
         
             
                      time_was = widget.updated_at
         
     | 
| 
       260 
     | 
    
         
            -
                       
     | 
| 
      
 287 
     | 
    
         
            +
                      # Travel 1 second because MySQL lacks sub-second resolution
         
     | 
| 
      
 288 
     | 
    
         
            +
                      Timecop.travel(1) do
         
     | 
| 
      
 289 
     | 
    
         
            +
                        widget.touch_with_version
         
     | 
| 
      
 290 
     | 
    
         
            +
                      end
         
     | 
| 
       261 
291 
     | 
    
         
             
                      expect(widget.updated_at).to be > time_was
         
     | 
| 
       262 
292 
     | 
    
         
             
                    end
         
     | 
| 
       263 
293 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -275,7 +305,7 @@ describe Widget, :type => :model do 
     | 
|
| 
       275 
305 
     | 
    
         
             
                  describe '#paper_trail_off!' do
         
     | 
| 
       276 
306 
     | 
    
         
             
                    it { is_expected.to respond_to(:paper_trail_off!) }
         
     | 
| 
       277 
307 
     | 
    
         | 
| 
       278 
     | 
    
         
            -
                    it  
     | 
| 
      
 308 
     | 
    
         
            +
                    it "should set the `paper_trail_enabled_for_model?` to `false`" do
         
     | 
| 
       279 
309 
     | 
    
         
             
                      expect(subject.paper_trail_enabled_for_model?).to be true
         
     | 
| 
       280 
310 
     | 
    
         
             
                      subject.paper_trail_off!
         
     | 
| 
       281 
311 
     | 
    
         
             
                      expect(subject.paper_trail_enabled_for_model?).to be false
         
     | 
| 
         @@ -287,7 +317,7 @@ describe Widget, :type => :model do 
     | 
|
| 
       287 
317 
     | 
    
         | 
| 
       288 
318 
     | 
    
         
             
                    it { is_expected.to respond_to(:paper_trail_on!) }
         
     | 
| 
       289 
319 
     | 
    
         | 
| 
       290 
     | 
    
         
            -
                    it  
     | 
| 
      
 320 
     | 
    
         
            +
                    it "should set the `paper_trail_enabled_for_model?` to `true`" do
         
     | 
| 
       291 
321 
     | 
    
         
             
                      expect(subject.paper_trail_enabled_for_model?).to be false
         
     | 
| 
       292 
322 
     | 
    
         
             
                      subject.paper_trail_on!
         
     | 
| 
       293 
323 
     | 
    
         
             
                      expect(subject.paper_trail_enabled_for_model?).to be true
         
     | 
| 
         @@ -1,30 +1,29 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "rails_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe PaperTrail::VersionConcern do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before(:all) { require "support/alt_db_init" }
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              it 'allows included class to have different connections' do
         
     | 
| 
      
 6 
     | 
    
         
            +
              it "allows included class to have different connections" do
         
     | 
| 
       8 
7 
     | 
    
         
             
                expect(Foo::Version.connection).not_to eq(Bar::Version.connection)
         
     | 
| 
       9 
8 
     | 
    
         
             
              end
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
              it  
     | 
| 
      
 10 
     | 
    
         
            +
              it "allows custom version class to share connection with superclass" do
         
     | 
| 
       12 
11 
     | 
    
         
             
                expect(Foo::Version.connection).to eq(Foo::Document.connection)
         
     | 
| 
       13 
12 
     | 
    
         
             
                expect(Bar::Version.connection).to eq(Bar::Document.connection)
         
     | 
| 
       14 
13 
     | 
    
         
             
              end
         
     | 
| 
       15 
14 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
              it  
     | 
| 
       17 
     | 
    
         
            -
                expect(Foo::Document.version_class_name).to eq( 
     | 
| 
       18 
     | 
    
         
            -
                expect(Bar::Document.version_class_name).to eq( 
     | 
| 
      
 15 
     | 
    
         
            +
              it "can be used with class_name option" do
         
     | 
| 
      
 16 
     | 
    
         
            +
                expect(Foo::Document.version_class_name).to eq("Foo::Version")
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(Bar::Document.version_class_name).to eq("Bar::Version")
         
     | 
| 
       19 
18 
     | 
    
         
             
              end
         
     | 
| 
       20 
19 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              describe  
     | 
| 
      
 20 
     | 
    
         
            +
              describe "persistence", versioning: true do
         
     | 
| 
       22 
21 
     | 
    
         
             
                before do
         
     | 
| 
       23 
     | 
    
         
            -
                  @foo_doc = Foo::Document.create!(: 
     | 
| 
       24 
     | 
    
         
            -
                  @bar_doc = Bar::Document.create!(: 
     | 
| 
      
 22 
     | 
    
         
            +
                  @foo_doc = Foo::Document.create!(name: "foobar")
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @bar_doc = Bar::Document.create!(name: "raboof")
         
     | 
| 
       25 
24 
     | 
    
         
             
                end
         
     | 
| 
       26 
25 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                it  
     | 
| 
      
 26 
     | 
    
         
            +
                it "should store versions in the correct corresponding db location" do
         
     | 
| 
       28 
27 
     | 
    
         
             
                  expect(@foo_doc.versions.first).to be_instance_of(Foo::Version)
         
     | 
| 
       29 
28 
     | 
    
         
             
                  expect(@bar_doc.versions.first).to be_instance_of(Bar::Version)
         
     | 
| 
       30 
29 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,7 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe PaperTrail::VERSION do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
4 
     | 
    
         
             
              describe "Constants" do
         
     | 
| 
       6 
5 
     | 
    
         
             
                subject { PaperTrail::VERSION }
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
         @@ -29,11 +28,10 @@ describe PaperTrail::VERSION do 
     | 
|
| 
       29 
28 
     | 
    
         | 
| 
       30 
29 
     | 
    
         
             
                  it "should join the numbers into a period separated string" do
         
     | 
| 
       31 
30 
     | 
    
         
             
                    expect(subject::STRING).to eq(
         
     | 
| 
       32 
     | 
    
         
            -
                      [subject::MAJOR, subject::MINOR, subject::TINY, subject::PRE].compact.join( 
     | 
| 
      
 31 
     | 
    
         
            +
                      [subject::MAJOR, subject::MINOR, subject::TINY, subject::PRE].compact.join("."))
         
     | 
| 
       33 
32 
     | 
    
         
             
                  end
         
     | 
| 
       34 
33 
     | 
    
         
             
                end
         
     | 
| 
       35 
34 
     | 
    
         
             
              end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
35 
     | 
    
         
             
            end
         
     | 
| 
       38 
36 
     | 
    
         | 
| 
       39 
37 
     | 
    
         
             
            describe PaperTrail do
         
     | 
| 
         @@ -14,37 +14,18 @@ module PaperTrail 
     | 
|
| 
       14 
14 
     | 
    
         
             
                  end
         
     | 
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                describe " 
     | 
| 
       18 
     | 
    
         
            -
                  context " 
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
       20 
     | 
    
         
            -
                       
     | 
| 
       21 
     | 
    
         
            -
                      allow(store).to receive(:fetch).
         
     | 
| 
       22 
     | 
    
         
            -
                        with(:paper_trail_enabled, true).
         
     | 
| 
       23 
     | 
    
         
            -
                        and_return(true)
         
     | 
| 
       24 
     | 
    
         
            -
                      allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
         
     | 
| 
       25 
     | 
    
         
            -
                      expect(described_class.instance.enabled).to eq(true)
         
     | 
| 
      
 17 
     | 
    
         
            +
                describe "track_associations?" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                  context "@track_associations is nil" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                    after do
         
     | 
| 
      
 20 
     | 
    
         
            +
                      PaperTrail.config.track_associations = true
         
     | 
| 
       26 
21 
     | 
    
         
             
                    end
         
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                  context "when paper_trail_enabled is false" do
         
     | 
| 
       30 
     | 
    
         
            -
                    it "returns false" do
         
     | 
| 
       31 
     | 
    
         
            -
                      store = double
         
     | 
| 
       32 
     | 
    
         
            -
                      allow(store).to receive(:fetch).
         
     | 
| 
       33 
     | 
    
         
            -
                        with(:paper_trail_enabled, true).
         
     | 
| 
       34 
     | 
    
         
            -
                        and_return(false)
         
     | 
| 
       35 
     | 
    
         
            -
                      allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
         
     | 
| 
       36 
     | 
    
         
            -
                      expect(described_class.instance.enabled).to eq(false)
         
     | 
| 
       37 
     | 
    
         
            -
                    end
         
     | 
| 
       38 
     | 
    
         
            -
                  end
         
     | 
| 
       39 
22 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                       
     | 
| 
       43 
     | 
    
         
            -
                       
     | 
| 
       44 
     | 
    
         
            -
                         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                      allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
         
     | 
| 
       47 
     | 
    
         
            -
                      expect(described_class.instance.enabled).to eq(true)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    it "returns false and prints a deprecation warning" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                      config = described_class.instance
         
     | 
| 
      
 25 
     | 
    
         
            +
                      config.track_associations = nil
         
     | 
| 
      
 26 
     | 
    
         
            +
                      expect {
         
     | 
| 
      
 27 
     | 
    
         
            +
                        expect(config.track_associations?).to eq(false)
         
     | 
| 
      
 28 
     | 
    
         
            +
                      }.to output(/DEPRECATION WARNING/).to_stderr
         
     | 
| 
       48 
29 
     | 
    
         
             
                    end
         
     | 
| 
       49 
30 
     | 
    
         
             
                  end
         
     | 
| 
       50 
31 
     | 
    
         
             
                end
         
     | 
    
        data/spec/paper_trail_spec.rb
    CHANGED
    
    | 
         @@ -1,11 +1,12 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "rails_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            describe  
     | 
| 
       4 
     | 
    
         
            -
              context  
     | 
| 
       5 
     | 
    
         
            -
                it  
     | 
| 
      
 3 
     | 
    
         
            +
            describe PaperTrail do
         
     | 
| 
      
 4 
     | 
    
         
            +
              context "default" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                it "should have versioning off by default" do
         
     | 
| 
       6 
6 
     | 
    
         
             
                  expect(PaperTrail).not_to be_enabled
         
     | 
| 
       7 
7 
     | 
    
         
             
                end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                it "should turn versioning on in a `with_versioning` block" do
         
     | 
| 
       9 
10 
     | 
    
         
             
                  expect(PaperTrail).not_to be_enabled
         
     | 
| 
       10 
11 
     | 
    
         
             
                  with_versioning do
         
     | 
| 
       11 
12 
     | 
    
         
             
                    expect(PaperTrail).to be_enabled
         
     | 
| 
         @@ -16,17 +17,18 @@ describe "PaperTrail RSpec Helper" do 
     | 
|
| 
       16 
17 
     | 
    
         
             
                context "error within `with_versioning` block" do
         
     | 
| 
       17 
18 
     | 
    
         
             
                  it "should revert the value of `PaperTrail.enabled?` to it's previous state" do
         
     | 
| 
       18 
19 
     | 
    
         
             
                    expect(PaperTrail).not_to be_enabled
         
     | 
| 
       19 
     | 
    
         
            -
                    expect { with_versioning { raise } }.to raise_error
         
     | 
| 
      
 20 
     | 
    
         
            +
                    expect { with_versioning { raise } }.to raise_error(RuntimeError)
         
     | 
| 
       20 
21 
     | 
    
         
             
                    expect(PaperTrail).not_to be_enabled
         
     | 
| 
       21 
22 
     | 
    
         
             
                  end
         
     | 
| 
       22 
23 
     | 
    
         
             
                end
         
     | 
| 
       23 
24 
     | 
    
         
             
              end
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
              context  
     | 
| 
       26 
     | 
    
         
            -
                it  
     | 
| 
      
 26 
     | 
    
         
            +
              context "`versioning: true`", versioning: true do
         
     | 
| 
      
 27 
     | 
    
         
            +
                it "should have versioning on by default" do
         
     | 
| 
       27 
28 
     | 
    
         
             
                  expect(PaperTrail).to be_enabled
         
     | 
| 
       28 
29 
     | 
    
         
             
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                it "should keep versioning on after a with_versioning block" do
         
     | 
| 
       30 
32 
     | 
    
         
             
                  expect(PaperTrail).to be_enabled
         
     | 
| 
       31 
33 
     | 
    
         
             
                  with_versioning do
         
     | 
| 
       32 
34 
     | 
    
         
             
                    expect(PaperTrail).to be_enabled
         
     | 
| 
         @@ -35,21 +37,21 @@ describe "PaperTrail RSpec Helper" do 
     | 
|
| 
       35 
37 
     | 
    
         
             
                end
         
     | 
| 
       36 
38 
     | 
    
         
             
              end
         
     | 
| 
       37 
39 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
              context  
     | 
| 
      
 40 
     | 
    
         
            +
              context "`with_versioning` block at class level" do
         
     | 
| 
       39 
41 
     | 
    
         
             
                it { expect(PaperTrail).not_to be_enabled }
         
     | 
| 
       40 
42 
     | 
    
         | 
| 
       41 
43 
     | 
    
         
             
                with_versioning do
         
     | 
| 
       42 
     | 
    
         
            -
                  it  
     | 
| 
      
 44 
     | 
    
         
            +
                  it "should have versioning on by default" do
         
     | 
| 
       43 
45 
     | 
    
         
             
                    expect(PaperTrail).to be_enabled
         
     | 
| 
       44 
46 
     | 
    
         
             
                  end
         
     | 
| 
       45 
47 
     | 
    
         
             
                end
         
     | 
| 
       46 
     | 
    
         
            -
                it  
     | 
| 
      
 48 
     | 
    
         
            +
                it "should not leak the `enabled?` state into successive tests" do
         
     | 
| 
       47 
49 
     | 
    
         
             
                  expect(PaperTrail).not_to be_enabled
         
     | 
| 
       48 
50 
     | 
    
         
             
                end
         
     | 
| 
       49 
51 
     | 
    
         
             
              end
         
     | 
| 
       50 
52 
     | 
    
         | 
| 
       51 
53 
     | 
    
         
             
              describe :whodunnit do
         
     | 
| 
       52 
     | 
    
         
            -
                before(:all) { PaperTrail.whodunnit =  
     | 
| 
      
 54 
     | 
    
         
            +
                before(:all) { PaperTrail.whodunnit = "foobar" }
         
     | 
| 
       53 
55 
     | 
    
         | 
| 
       54 
56 
     | 
    
         
             
                it "should get set to `nil` by default" do
         
     | 
| 
       55 
57 
     | 
    
         
             
                  expect(PaperTrail.whodunnit).to be_nil
         
     | 
| 
         @@ -57,7 +59,7 @@ describe "PaperTrail RSpec Helper" do 
     | 
|
| 
       57 
59 
     | 
    
         
             
              end
         
     | 
| 
       58 
60 
     | 
    
         | 
| 
       59 
61 
     | 
    
         
             
              describe :controller_info do
         
     | 
| 
       60 
     | 
    
         
            -
                before(:all) { ::PaperTrail.controller_info = {: 
     | 
| 
      
 62 
     | 
    
         
            +
                before(:all) { ::PaperTrail.controller_info = { foo: "bar" } }
         
     | 
| 
       61 
63 
     | 
    
         | 
| 
       62 
64 
     | 
    
         
             
                it "should get set to an empty hash before each test" do
         
     | 
| 
       63 
65 
     | 
    
         
             
                  expect(PaperTrail.controller_info).to eq({})
         
     |