paper_trail 6.0.2 → 7.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/.github/CONTRIBUTING.md +20 -0
- data/.rubocop.yml +30 -2
- data/.rubocop_todo.yml +20 -0
- data/.travis.yml +3 -5
- data/Appraisals +5 -6
- data/CHANGELOG.md +33 -0
- data/README.md +43 -81
- data/Rakefile +1 -1
- data/doc/bug_report_template.rb +4 -2
- data/gemfiles/ar_4.0.gemfile +7 -0
- data/gemfiles/ar_4.2.gemfile +0 -1
- data/lib/generators/paper_trail/templates/create_version_associations.rb +1 -1
- data/lib/generators/paper_trail/templates/create_versions.rb +1 -1
- data/lib/paper_trail.rb +7 -9
- data/lib/paper_trail/config.rb +0 -15
- data/lib/paper_trail/frameworks/rspec.rb +8 -2
- data/lib/paper_trail/model_config.rb +6 -2
- data/lib/paper_trail/record_trail.rb +3 -1
- data/lib/paper_trail/reifier.rb +43 -354
- data/lib/paper_trail/reifiers/belongs_to.rb +48 -0
- data/lib/paper_trail/reifiers/has_and_belongs_to_many.rb +50 -0
- data/lib/paper_trail/reifiers/has_many.rb +110 -0
- data/lib/paper_trail/reifiers/has_many_through.rb +90 -0
- data/lib/paper_trail/reifiers/has_one.rb +76 -0
- data/lib/paper_trail/serializers/yaml.rb +2 -25
- data/lib/paper_trail/version_concern.rb +5 -5
- data/lib/paper_trail/version_number.rb +7 -3
- data/paper_trail.gemspec +7 -34
- data/spec/controllers/articles_controller_spec.rb +1 -1
- data/spec/generators/install_generator_spec.rb +40 -34
- data/spec/models/animal_spec.rb +50 -25
- data/spec/models/boolit_spec.rb +8 -7
- data/spec/models/callback_modifier_spec.rb +13 -13
- data/spec/models/document_spec.rb +21 -0
- data/spec/models/gadget_spec.rb +35 -39
- data/spec/models/joined_version_spec.rb +4 -4
- data/spec/models/json_version_spec.rb +14 -15
- data/spec/models/not_on_update_spec.rb +1 -1
- data/spec/models/post_with_status_spec.rb +2 -2
- data/spec/models/skipper_spec.rb +4 -4
- data/spec/models/thing_spec.rb +1 -1
- data/spec/models/truck_spec.rb +1 -1
- data/spec/models/vehicle_spec.rb +1 -1
- data/spec/models/version_spec.rb +152 -168
- data/spec/models/widget_spec.rb +170 -196
- data/spec/modules/paper_trail_spec.rb +3 -3
- data/spec/modules/version_concern_spec.rb +5 -8
- data/spec/modules/version_number_spec.rb +11 -36
- data/spec/paper_trail/cleaner_spec.rb +152 -0
- data/spec/paper_trail/config_spec.rb +1 -1
- data/spec/paper_trail/serializers/custom_yaml_serializer_spec.rb +45 -0
- data/spec/paper_trail/serializers/json_spec.rb +57 -0
- data/spec/paper_trail/version_limit_spec.rb +55 -0
- data/spec/paper_trail_spec.rb +45 -32
- data/spec/requests/articles_spec.rb +4 -4
- data/test/dummy/app/models/custom_primary_key_record.rb +4 -2
- data/test/dummy/app/models/document.rb +1 -1
- data/test/dummy/app/models/not_on_update.rb +1 -1
- data/test/dummy/app/models/on/create.rb +6 -0
- data/test/dummy/app/models/on/destroy.rb +6 -0
- data/test/dummy/app/models/on/empty_array.rb +6 -0
- data/test/dummy/app/models/on/update.rb +6 -0
- data/test/dummy/app/models/person.rb +1 -0
- data/test/dummy/app/models/song.rb +19 -28
- data/test/dummy/config/application.rb +10 -43
- data/test/dummy/config/routes.rb +1 -1
- data/test/dummy/db/migrate/20110208155312_set_up_test_tables.rb +25 -51
- data/test/dummy/db/schema.rb +29 -19
- data/test/test_helper.rb +0 -16
- data/test/unit/associations_test.rb +81 -81
- data/test/unit/model_test.rb +48 -131
- data/test/unit/serializer_test.rb +34 -45
- data/test/unit/serializers/mixin_json_test.rb +3 -1
- data/test/unit/serializers/yaml_test.rb +1 -5
- metadata +44 -19
- data/lib/paper_trail/frameworks/sinatra.rb +0 -40
- data/test/functional/modular_sinatra_test.rb +0 -46
- data/test/functional/sinatra_test.rb +0 -51
- data/test/unit/cleaner_test.rb +0 -151
- data/test/unit/inheritance_column_test.rb +0 -41
- data/test/unit/serializers/json_test.rb +0 -95
- data/test/unit/serializers/mixin_yaml_test.rb +0 -53
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -98,19 +98,3 @@ def params_wrapper(args) | |
| 98 98 | 
             
                args
         | 
| 99 99 | 
             
              end
         | 
| 100 100 | 
             
            end
         | 
| 101 | 
            -
             | 
| 102 | 
            -
            module CleanupCallbacks
         | 
| 103 | 
            -
              def cleanup_callbacks(target, type)
         | 
| 104 | 
            -
                original_callbacks = nil
         | 
| 105 | 
            -
             | 
| 106 | 
            -
                setup do
         | 
| 107 | 
            -
                  original_callbacks = target.send(:get_callbacks, type).deep_dup
         | 
| 108 | 
            -
                end
         | 
| 109 | 
            -
             | 
| 110 | 
            -
                teardown do
         | 
| 111 | 
            -
                  if original_callbacks
         | 
| 112 | 
            -
                    target.send(:set_callbacks, type, original_callbacks)
         | 
| 113 | 
            -
                  end
         | 
| 114 | 
            -
                end
         | 
| 115 | 
            -
              end
         | 
| 116 | 
            -
            end
         | 
| @@ -43,10 +43,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 43 43 | 
             
                  end
         | 
| 44 44 |  | 
| 45 45 | 
             
                  context "when reified" do
         | 
| 46 | 
            -
                    setup { @ | 
| 46 | 
            +
                    setup { @widget0 = @widget.versions.last.reify(has_one: true) }
         | 
| 47 47 |  | 
| 48 48 | 
             
                    should "see the associated as it was at the time" do
         | 
| 49 | 
            -
                      assert_nil @ | 
| 49 | 
            +
                      assert_nil @widget0.wotsit
         | 
| 50 50 | 
             
                    end
         | 
| 51 51 |  | 
| 52 52 | 
             
                    should "not persist changes to the live association" do
         | 
| @@ -63,10 +63,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 63 63 | 
             
                  end
         | 
| 64 64 |  | 
| 65 65 | 
             
                  context "when reified" do
         | 
| 66 | 
            -
                    setup { @ | 
| 66 | 
            +
                    setup { @widget0 = @widget.versions.last.reify(has_one: true) }
         | 
| 67 67 |  | 
| 68 68 | 
             
                    should "see the associated as it was at the time" do
         | 
| 69 | 
            -
                      assert_equal "wotsit_0", @ | 
| 69 | 
            +
                      assert_equal "wotsit_0", @widget0.wotsit.name
         | 
| 70 70 | 
             
                    end
         | 
| 71 71 |  | 
| 72 72 | 
             
                    should "not persist changes to the live association" do
         | 
| @@ -84,10 +84,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 84 84 | 
             
                    end
         | 
| 85 85 |  | 
| 86 86 | 
             
                    context "when reified" do
         | 
| 87 | 
            -
                      setup { @ | 
| 87 | 
            +
                      setup { @widget1 = @widget.versions.last.reify(has_one: true) }
         | 
| 88 88 |  | 
| 89 89 | 
             
                      should "see the associated as it was at the time" do
         | 
| 90 | 
            -
                        assert_equal "wotsit_2", @ | 
| 90 | 
            +
                        assert_equal "wotsit_2", @widget1.wotsit.name
         | 
| 91 91 | 
             
                      end
         | 
| 92 92 |  | 
| 93 93 | 
             
                      should "not persist changes to the live association" do
         | 
| @@ -96,10 +96,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 96 96 | 
             
                    end
         | 
| 97 97 |  | 
| 98 98 | 
             
                    context "when reified opting out of has_one reification" do
         | 
| 99 | 
            -
                      setup { @ | 
| 99 | 
            +
                      setup { @widget1 = @widget.versions.last.reify(has_one: false) }
         | 
| 100 100 |  | 
| 101 101 | 
             
                      should "see the associated as it is live" do
         | 
| 102 | 
            -
                        assert_equal "wotsit_3", @ | 
| 102 | 
            +
                        assert_equal "wotsit_3", @widget1.wotsit.name
         | 
| 103 103 | 
             
                      end
         | 
| 104 104 | 
             
                    end
         | 
| 105 105 | 
             
                  end
         | 
| @@ -110,10 +110,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 110 110 | 
             
                    end
         | 
| 111 111 |  | 
| 112 112 | 
             
                    context "when reify" do
         | 
| 113 | 
            -
                      setup { @ | 
| 113 | 
            +
                      setup { @widget1 = @widget.versions.last.reify(has_one: true) }
         | 
| 114 114 |  | 
| 115 115 | 
             
                      should "see the associated as it was at the time" do
         | 
| 116 | 
            -
                        assert_equal @wotsit, @ | 
| 116 | 
            +
                        assert_equal @wotsit, @widget1.wotsit
         | 
| 117 117 | 
             
                      end
         | 
| 118 118 |  | 
| 119 119 | 
             
                      should "not persist changes to the live association" do
         | 
| @@ -128,10 +128,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 128 128 | 
             
                      end
         | 
| 129 129 |  | 
| 130 130 | 
             
                      context "when reified" do
         | 
| 131 | 
            -
                        setup { @ | 
| 131 | 
            +
                        setup { @widget2 = @widget.versions.last.reify(has_one: true) }
         | 
| 132 132 |  | 
| 133 133 | 
             
                        should "see the associated as it was at the time" do
         | 
| 134 | 
            -
                          assert_nil @ | 
| 134 | 
            +
                          assert_nil @widget2.wotsit
         | 
| 135 135 | 
             
                        end
         | 
| 136 136 | 
             
                      end
         | 
| 137 137 | 
             
                    end
         | 
| @@ -149,10 +149,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 149 149 | 
             
                  end
         | 
| 150 150 |  | 
| 151 151 | 
             
                  context "when reified" do
         | 
| 152 | 
            -
                    setup { @ | 
| 152 | 
            +
                    setup { @customer0 = @customer.versions.last.reify(has_many: true) }
         | 
| 153 153 |  | 
| 154 154 | 
             
                    should "see the associated as it was at the time" do
         | 
| 155 | 
            -
                      assert_equal [], @ | 
| 155 | 
            +
                      assert_equal [], @customer0.orders
         | 
| 156 156 | 
             
                    end
         | 
| 157 157 |  | 
| 158 158 | 
             
                    should "not persist changes to the live association" do
         | 
| @@ -162,11 +162,11 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 162 162 |  | 
| 163 163 | 
             
                  context "when reified with option mark_for_destruction" do
         | 
| 164 164 | 
             
                    should "mark the associated for destruction" do
         | 
| 165 | 
            -
                      @ | 
| 165 | 
            +
                      @customer0 = @customer.versions.last.reify(
         | 
| 166 166 | 
             
                        has_many: true,
         | 
| 167 167 | 
             
                        mark_for_destruction: true
         | 
| 168 168 | 
             
                      )
         | 
| 169 | 
            -
                      assert_equal [true], @ | 
| 169 | 
            +
                      assert_equal [true], @customer0.orders.map(&:marked_for_destruction?)
         | 
| 170 170 | 
             
                    end
         | 
| 171 171 | 
             
                  end
         | 
| 172 172 | 
             
                end
         | 
| @@ -179,10 +179,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 179 179 | 
             
                  end
         | 
| 180 180 |  | 
| 181 181 | 
             
                  context "when reified" do
         | 
| 182 | 
            -
                    setup { @ | 
| 182 | 
            +
                    setup { @customer0 = @customer.versions.last.reify(has_many: true) }
         | 
| 183 183 |  | 
| 184 184 | 
             
                    should "see the associated as it was at the time" do
         | 
| 185 | 
            -
                      assert_equal ["order_date_0"], @ | 
| 185 | 
            +
                      assert_equal ["order_date_0"], @customer0.orders.map(&:order_date)
         | 
| 186 186 | 
             
                    end
         | 
| 187 187 | 
             
                  end
         | 
| 188 188 |  | 
| @@ -192,10 +192,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 192 192 | 
             
                    end
         | 
| 193 193 |  | 
| 194 194 | 
             
                    context "when reified" do
         | 
| 195 | 
            -
                      setup { @ | 
| 195 | 
            +
                      setup { @customer0 = @customer.versions.last.reify(has_many: true) }
         | 
| 196 196 |  | 
| 197 197 | 
             
                      should "see the live version of the nested association" do
         | 
| 198 | 
            -
                        assert_equal ["product_0"], @ | 
| 198 | 
            +
                        assert_equal ["product_0"], @customer0.orders.first.line_items.map(&:product)
         | 
| 199 199 | 
             
                      end
         | 
| 200 200 | 
             
                    end
         | 
| 201 201 | 
             
                  end
         | 
| @@ -210,10 +210,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 210 210 | 
             
                    end
         | 
| 211 211 |  | 
| 212 212 | 
             
                    context "when reified" do
         | 
| 213 | 
            -
                      setup { @ | 
| 213 | 
            +
                      setup { @customer1 = @customer.versions.last.reify(has_many: true) }
         | 
| 214 214 |  | 
| 215 215 | 
             
                      should "see the associated as it was at the time" do
         | 
| 216 | 
            -
                        assert_equal ["order_date_2"], @ | 
| 216 | 
            +
                        assert_equal ["order_date_2"], @customer1.orders.map(&:order_date)
         | 
| 217 217 | 
             
                      end
         | 
| 218 218 |  | 
| 219 219 | 
             
                      should "not persist changes to the live association" do
         | 
| @@ -222,10 +222,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 222 222 | 
             
                    end
         | 
| 223 223 |  | 
| 224 224 | 
             
                    context "when reified opting out of has_many reification" do
         | 
| 225 | 
            -
                      setup { @ | 
| 225 | 
            +
                      setup { @customer1 = @customer.versions.last.reify(has_many: false) }
         | 
| 226 226 |  | 
| 227 227 | 
             
                      should "see the associated as it is live" do
         | 
| 228 | 
            -
                        assert_equal ["order_date_3"], @ | 
| 228 | 
            +
                        assert_equal ["order_date_3"], @customer1.orders.map(&:order_date)
         | 
| 229 229 | 
             
                      end
         | 
| 230 230 | 
             
                    end
         | 
| 231 231 |  | 
| @@ -235,10 +235,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 235 235 | 
             
                      end
         | 
| 236 236 |  | 
| 237 237 | 
             
                      context "when reified" do
         | 
| 238 | 
            -
                        setup { @ | 
| 238 | 
            +
                        setup { @customer1 = @customer.versions.last.reify(has_many: true) }
         | 
| 239 239 |  | 
| 240 240 | 
             
                        should "see the associated as it was at the time" do
         | 
| 241 | 
            -
                          assert_equal ["order_date_2"], @ | 
| 241 | 
            +
                          assert_equal ["order_date_2"], @customer1.orders.map(&:order_date)
         | 
| 242 242 | 
             
                        end
         | 
| 243 243 |  | 
| 244 244 | 
             
                        should "not persist changes to the live association" do
         | 
| @@ -254,10 +254,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 254 254 | 
             
                    end
         | 
| 255 255 |  | 
| 256 256 | 
             
                    context "when reified" do
         | 
| 257 | 
            -
                      setup { @ | 
| 257 | 
            +
                      setup { @customer1 = @customer.versions.last.reify(has_many: true) }
         | 
| 258 258 |  | 
| 259 259 | 
             
                      should "see the associated as it was at the time" do
         | 
| 260 | 
            -
                        assert_equal [@order.order_date], @ | 
| 260 | 
            +
                        assert_equal [@order.order_date], @customer1.orders.map(&:order_date)
         | 
| 261 261 | 
             
                      end
         | 
| 262 262 |  | 
| 263 263 | 
             
                      should "not persist changes to the live association" do
         | 
| @@ -274,10 +274,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 274 274 | 
             
                    end
         | 
| 275 275 |  | 
| 276 276 | 
             
                    context "when reified" do
         | 
| 277 | 
            -
                      setup { @ | 
| 277 | 
            +
                      setup { @customer1 = @customer.versions.last.reify(has_many: true) }
         | 
| 278 278 |  | 
| 279 279 | 
             
                      should "see the associated as it was at the time" do
         | 
| 280 | 
            -
                        assert_equal [], @ | 
| 280 | 
            +
                        assert_equal [], @customer1.orders
         | 
| 281 281 | 
             
                      end
         | 
| 282 282 | 
             
                    end
         | 
| 283 283 | 
             
                  end
         | 
| @@ -288,10 +288,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 288 288 | 
             
                    end
         | 
| 289 289 |  | 
| 290 290 | 
             
                    context "when reified" do
         | 
| 291 | 
            -
                      setup { @ | 
| 291 | 
            +
                      setup { @customer0 = @customer.versions.last.reify(has_many: true) }
         | 
| 292 292 |  | 
| 293 293 | 
             
                      should "see the associated as it was at the time" do
         | 
| 294 | 
            -
                        assert_equal ["order_date_0"], @ | 
| 294 | 
            +
                        assert_equal ["order_date_0"], @customer0.orders.map(&:order_date)
         | 
| 295 295 | 
             
                      end
         | 
| 296 296 |  | 
| 297 297 | 
             
                      should "not persist changes to the live association" do
         | 
| @@ -302,11 +302,11 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 302 302 |  | 
| 303 303 | 
             
                    context "when reified with option mark_for_destruction" do
         | 
| 304 304 | 
             
                      should "mark the newly associated for destruction" do
         | 
| 305 | 
            -
                        @ | 
| 305 | 
            +
                        @customer0 = @customer.versions.last.reify(
         | 
| 306 306 | 
             
                          has_many: true,
         | 
| 307 307 | 
             
                          mark_for_destruction: true
         | 
| 308 308 | 
             
                        )
         | 
| 309 | 
            -
                        assert @ | 
| 309 | 
            +
                        assert @customer0.
         | 
| 310 310 | 
             
                          orders.
         | 
| 311 311 | 
             
                          detect { |o| o.order_date == "order_date_1" }.
         | 
| 312 312 | 
             
                          marked_for_destruction?
         | 
| @@ -327,10 +327,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 327 327 | 
             
                    end
         | 
| 328 328 |  | 
| 329 329 | 
             
                    context "when reified" do
         | 
| 330 | 
            -
                      setup { @ | 
| 330 | 
            +
                      setup { @book0 = @book.versions.last.reify(has_many: true) }
         | 
| 331 331 |  | 
| 332 332 | 
             
                      should "see the associated as it was at the time" do
         | 
| 333 | 
            -
                        assert_equal [], @ | 
| 333 | 
            +
                        assert_equal [], @book0.authors
         | 
| 334 334 | 
             
                      end
         | 
| 335 335 |  | 
| 336 336 | 
             
                      should "not persist changes to the live association" do
         | 
| @@ -340,18 +340,18 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 340 340 |  | 
| 341 341 | 
             
                    context "when reified with option mark_for_destruction" do
         | 
| 342 342 | 
             
                      setup do
         | 
| 343 | 
            -
                        @ | 
| 343 | 
            +
                        @book0 = @book.versions.last.reify(
         | 
| 344 344 | 
             
                          has_many: true,
         | 
| 345 345 | 
             
                          mark_for_destruction: true
         | 
| 346 346 | 
             
                        )
         | 
| 347 347 | 
             
                      end
         | 
| 348 348 |  | 
| 349 349 | 
             
                      should "mark the associated for destruction" do
         | 
| 350 | 
            -
                        assert_equal [true], @ | 
| 350 | 
            +
                        assert_equal [true], @book0.authors.map(&:marked_for_destruction?)
         | 
| 351 351 | 
             
                      end
         | 
| 352 352 |  | 
| 353 353 | 
             
                      should "mark the associated-through for destruction" do
         | 
| 354 | 
            -
                        assert_equal [true], @ | 
| 354 | 
            +
                        assert_equal [true], @book0.authorships.map(&:marked_for_destruction?)
         | 
| 355 355 | 
             
                      end
         | 
| 356 356 | 
             
                    end
         | 
| 357 357 | 
             
                  end
         | 
| @@ -366,28 +366,28 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 366 366 |  | 
| 367 367 | 
             
                    context "when reified" do
         | 
| 368 368 | 
             
                      setup do
         | 
| 369 | 
            -
                        @ | 
| 369 | 
            +
                        @book0 = @book.versions.last.reify(has_many: true)
         | 
| 370 370 | 
             
                      end
         | 
| 371 371 |  | 
| 372 372 | 
             
                      should "see the associated as it was at the time" do
         | 
| 373 | 
            -
                        assert_equal [], @ | 
| 373 | 
            +
                        assert_equal [], @book0.authors
         | 
| 374 374 | 
             
                      end
         | 
| 375 375 | 
             
                    end
         | 
| 376 376 |  | 
| 377 377 | 
             
                    context "when reified with option mark_for_destruction" do
         | 
| 378 378 | 
             
                      setup do
         | 
| 379 | 
            -
                        @ | 
| 379 | 
            +
                        @book0 = @book.versions.last.reify(
         | 
| 380 380 | 
             
                          has_many: true,
         | 
| 381 381 | 
             
                          mark_for_destruction: true
         | 
| 382 382 | 
             
                        )
         | 
| 383 383 | 
             
                      end
         | 
| 384 384 |  | 
| 385 385 | 
             
                      should "not mark the associated for destruction" do
         | 
| 386 | 
            -
                        assert_equal [false], @ | 
| 386 | 
            +
                        assert_equal [false], @book0.authors.map(&:marked_for_destruction?)
         | 
| 387 387 | 
             
                      end
         | 
| 388 388 |  | 
| 389 389 | 
             
                      should "mark the associated-through for destruction" do
         | 
| 390 | 
            -
                        assert_equal [true], @ | 
| 390 | 
            +
                        assert_equal [true], @book0.authorships.map(&:marked_for_destruction?)
         | 
| 391 391 | 
             
                      end
         | 
| 392 392 | 
             
                    end
         | 
| 393 393 | 
             
                  end
         | 
| @@ -401,10 +401,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 401 401 | 
             
                    end
         | 
| 402 402 |  | 
| 403 403 | 
             
                    context "when reified" do
         | 
| 404 | 
            -
                      setup { @ | 
| 404 | 
            +
                      setup { @book0 = @book.versions.last.reify(has_many: true) }
         | 
| 405 405 |  | 
| 406 406 | 
             
                      should "see the associated as it was at the time" do
         | 
| 407 | 
            -
                        assert_equal ["author_0"], @ | 
| 407 | 
            +
                        assert_equal ["author_0"], @book0.authors.map(&:name)
         | 
| 408 408 | 
             
                      end
         | 
| 409 409 | 
             
                    end
         | 
| 410 410 |  | 
| @@ -418,10 +418,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 418 418 | 
             
                      end
         | 
| 419 419 |  | 
| 420 420 | 
             
                      context "when reified" do
         | 
| 421 | 
            -
                        setup { @ | 
| 421 | 
            +
                        setup { @book1 = @book.versions.last.reify(has_many: true) }
         | 
| 422 422 |  | 
| 423 423 | 
             
                        should "see the associated as it was at the time" do
         | 
| 424 | 
            -
                          assert_equal ["author_2"], @ | 
| 424 | 
            +
                          assert_equal ["author_2"], @book1.authors.map(&:name)
         | 
| 425 425 | 
             
                        end
         | 
| 426 426 |  | 
| 427 427 | 
             
                        should "not persist changes to the live association" do
         | 
| @@ -430,10 +430,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 430 430 | 
             
                      end
         | 
| 431 431 |  | 
| 432 432 | 
             
                      context "when reified opting out of has_many reification" do
         | 
| 433 | 
            -
                        setup { @ | 
| 433 | 
            +
                        setup { @book1 = @book.versions.last.reify(has_many: false) }
         | 
| 434 434 |  | 
| 435 435 | 
             
                        should "see the associated as it is live" do
         | 
| 436 | 
            -
                          assert_equal ["author_3"], @ | 
| 436 | 
            +
                          assert_equal ["author_3"], @book1.authors.map(&:name)
         | 
| 437 437 | 
             
                        end
         | 
| 438 438 | 
             
                      end
         | 
| 439 439 | 
             
                    end
         | 
| @@ -444,10 +444,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 444 444 | 
             
                      end
         | 
| 445 445 |  | 
| 446 446 | 
             
                      context "when reified" do
         | 
| 447 | 
            -
                        setup { @ | 
| 447 | 
            +
                        setup { @book1 = @book.versions.last.reify(has_many: true) }
         | 
| 448 448 |  | 
| 449 449 | 
             
                        should "see the associated as it was at the time" do
         | 
| 450 | 
            -
                          assert_equal [@author.name], @ | 
| 450 | 
            +
                          assert_equal [@author.name], @book1.authors.map(&:name)
         | 
| 451 451 | 
             
                        end
         | 
| 452 452 |  | 
| 453 453 | 
             
                        should "not persist changes to the live association" do
         | 
| @@ -464,10 +464,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 464 464 | 
             
                      end
         | 
| 465 465 |  | 
| 466 466 | 
             
                      context "when reified" do
         | 
| 467 | 
            -
                        setup { @ | 
| 467 | 
            +
                        setup { @book1 = @book.versions.last.reify(has_many: true) }
         | 
| 468 468 |  | 
| 469 469 | 
             
                        should "see the associated as it was at the time" do
         | 
| 470 | 
            -
                          assert_equal [], @ | 
| 470 | 
            +
                          assert_equal [], @book1.authors
         | 
| 471 471 | 
             
                        end
         | 
| 472 472 | 
             
                      end
         | 
| 473 473 | 
             
                    end
         | 
| @@ -480,10 +480,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 480 480 | 
             
                      end
         | 
| 481 481 |  | 
| 482 482 | 
             
                      context "when reified" do
         | 
| 483 | 
            -
                        setup { @ | 
| 483 | 
            +
                        setup { @book1 = @book.versions.last.reify(has_many: true) }
         | 
| 484 484 |  | 
| 485 485 | 
             
                        should "see the associated as it was at the time" do
         | 
| 486 | 
            -
                          assert_equal [], @ | 
| 486 | 
            +
                          assert_equal [], @book1.authors
         | 
| 487 487 | 
             
                        end
         | 
| 488 488 | 
             
                      end
         | 
| 489 489 | 
             
                    end
         | 
| @@ -494,10 +494,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 494 494 | 
             
                      end
         | 
| 495 495 |  | 
| 496 496 | 
             
                      context "when reified" do
         | 
| 497 | 
            -
                        setup { @ | 
| 497 | 
            +
                        setup { @book0 = @book.versions.last.reify(has_many: true) }
         | 
| 498 498 |  | 
| 499 499 | 
             
                        should "only see the first associated" do
         | 
| 500 | 
            -
                          assert_equal ["author_0"], @ | 
| 500 | 
            +
                          assert_equal ["author_0"], @book0.authors.map(&:name)
         | 
| 501 501 | 
             
                        end
         | 
| 502 502 |  | 
| 503 503 | 
             
                        should "not persist changes to the live association" do
         | 
| @@ -507,21 +507,21 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 507 507 |  | 
| 508 508 | 
             
                      context "when reified with option mark_for_destruction" do
         | 
| 509 509 | 
             
                        setup do
         | 
| 510 | 
            -
                          @ | 
| 510 | 
            +
                          @book0 = @book.versions.last.reify(
         | 
| 511 511 | 
             
                            has_many: true,
         | 
| 512 512 | 
             
                            mark_for_destruction: true
         | 
| 513 513 | 
             
                          )
         | 
| 514 514 | 
             
                        end
         | 
| 515 515 |  | 
| 516 516 | 
             
                        should "mark the newly associated for destruction" do
         | 
| 517 | 
            -
                          assert @ | 
| 517 | 
            +
                          assert @book0.
         | 
| 518 518 | 
             
                            authors.
         | 
| 519 519 | 
             
                            detect { |a| a.name == "author_1" }.
         | 
| 520 520 | 
             
                            marked_for_destruction?
         | 
| 521 521 | 
             
                        end
         | 
| 522 522 |  | 
| 523 523 | 
             
                        should "mark the newly associated-through for destruction" do
         | 
| 524 | 
            -
                          assert @ | 
| 524 | 
            +
                          assert @book0.
         | 
| 525 525 | 
             
                            authorships.
         | 
| 526 526 | 
             
                            detect { |as| as.author.name == "author_1" }.
         | 
| 527 527 | 
             
                            marked_for_destruction?
         | 
| @@ -535,10 +535,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 535 535 | 
             
                      end
         | 
| 536 536 |  | 
| 537 537 | 
             
                      context "when reified" do
         | 
| 538 | 
            -
                        setup { @ | 
| 538 | 
            +
                        setup { @book0 = @book.versions.last.reify(has_many: true) }
         | 
| 539 539 |  | 
| 540 540 | 
             
                        should "only see the first associated" do
         | 
| 541 | 
            -
                          assert_equal ["author_0"], @ | 
| 541 | 
            +
                          assert_equal ["author_0"], @book0.authors.map(&:name)
         | 
| 542 542 | 
             
                        end
         | 
| 543 543 |  | 
| 544 544 | 
             
                        should "not persist changes to the live association" do
         | 
| @@ -548,21 +548,21 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 548 548 |  | 
| 549 549 | 
             
                      context "when reified with option mark_for_destruction" do
         | 
| 550 550 | 
             
                        setup do
         | 
| 551 | 
            -
                          @ | 
| 551 | 
            +
                          @book0 = @book.versions.last.reify(
         | 
| 552 552 | 
             
                            has_many: true,
         | 
| 553 553 | 
             
                            mark_for_destruction: true
         | 
| 554 554 | 
             
                          )
         | 
| 555 555 | 
             
                        end
         | 
| 556 556 |  | 
| 557 557 | 
             
                        should "not mark the newly associated for destruction" do
         | 
| 558 | 
            -
                          assert !@ | 
| 558 | 
            +
                          assert !@book0.
         | 
| 559 559 | 
             
                            authors.
         | 
| 560 560 | 
             
                            detect { |a| a.name == "person_existing" }.
         | 
| 561 561 | 
             
                            marked_for_destruction?
         | 
| 562 562 | 
             
                        end
         | 
| 563 563 |  | 
| 564 564 | 
             
                        should "mark the newly associated-through for destruction" do
         | 
| 565 | 
            -
                          assert @ | 
| 565 | 
            +
                          assert @book0.
         | 
| 566 566 | 
             
                            authorships.
         | 
| 567 567 | 
             
                            detect { |as| as.author.name == "person_existing" }.
         | 
| 568 568 | 
             
                            marked_for_destruction?
         | 
| @@ -578,10 +578,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 578 578 | 
             
                    end
         | 
| 579 579 |  | 
| 580 580 | 
             
                    context "when reified" do
         | 
| 581 | 
            -
                      setup { @ | 
| 581 | 
            +
                      setup { @book0 = @book.versions.last.reify(has_many: true) }
         | 
| 582 582 |  | 
| 583 583 | 
             
                      should "see the live association" do
         | 
| 584 | 
            -
                        assert_equal ["editor_0"], @ | 
| 584 | 
            +
                        assert_equal ["editor_0"], @book0.editors.map(&:name)
         | 
| 585 585 | 
             
                      end
         | 
| 586 586 | 
             
                    end
         | 
| 587 587 | 
             
                  end
         | 
| @@ -782,10 +782,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 782 782 | 
             
                    end
         | 
| 783 783 |  | 
| 784 784 | 
             
                    context "when reified" do
         | 
| 785 | 
            -
                      setup { @ | 
| 785 | 
            +
                      setup { @wotsit0 = @wotsit.versions.last.reify(belongs_to: true) }
         | 
| 786 786 |  | 
| 787 787 | 
             
                      should "see the associated as it was at the time" do
         | 
| 788 | 
            -
                        assert_nil @ | 
| 788 | 
            +
                        assert_nil @wotsit0.widget
         | 
| 789 789 | 
             
                      end
         | 
| 790 790 |  | 
| 791 791 | 
             
                      should "not persist changes to the live association" do
         | 
| @@ -803,10 +803,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 803 803 | 
             
                      end
         | 
| 804 804 |  | 
| 805 805 | 
             
                      context "when reified" do
         | 
| 806 | 
            -
                        setup { @ | 
| 806 | 
            +
                        setup { @wotsit1 = @wotsit.versions.last.reify(belongs_to: true) }
         | 
| 807 807 |  | 
| 808 808 | 
             
                        should "see the associated as it was at the time" do
         | 
| 809 | 
            -
                          assert_equal "widget_2", @ | 
| 809 | 
            +
                          assert_equal "widget_2", @wotsit1.widget.name
         | 
| 810 810 | 
             
                        end
         | 
| 811 811 |  | 
| 812 812 | 
             
                        should "not persist changes to the live association" do
         | 
| @@ -815,10 +815,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 815 815 | 
             
                      end
         | 
| 816 816 |  | 
| 817 817 | 
             
                      context "when reified opting out of belongs_to reification" do
         | 
| 818 | 
            -
                        setup { @ | 
| 818 | 
            +
                        setup { @wotsit1 = @wotsit.versions.last.reify(belongs_to: false) }
         | 
| 819 819 |  | 
| 820 820 | 
             
                        should "see the associated as it is live" do
         | 
| 821 | 
            -
                          assert_equal "widget_3", @ | 
| 821 | 
            +
                          assert_equal "widget_3", @wotsit1.widget.name
         | 
| 822 822 | 
             
                        end
         | 
| 823 823 | 
             
                      end
         | 
| 824 824 | 
             
                    end
         | 
| @@ -830,10 +830,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 830 830 | 
             
                      end
         | 
| 831 831 |  | 
| 832 832 | 
             
                      context "when reified" do
         | 
| 833 | 
            -
                        setup { @ | 
| 833 | 
            +
                        setup { @wotsit2 = @wotsit.versions.last.reify(belongs_to: true) }
         | 
| 834 834 |  | 
| 835 835 | 
             
                        should "see the associated as it was at the time" do
         | 
| 836 | 
            -
                          assert_equal @widget, @ | 
| 836 | 
            +
                          assert_equal @widget, @wotsit2.widget
         | 
| 837 837 | 
             
                        end
         | 
| 838 838 |  | 
| 839 839 | 
             
                        should "not persist changes to the live association" do
         | 
| @@ -848,10 +848,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 848 848 | 
             
                        end
         | 
| 849 849 |  | 
| 850 850 | 
             
                        context "when reified" do
         | 
| 851 | 
            -
                          setup { @ | 
| 851 | 
            +
                          setup { @wotsit2 = @wotsit.versions.last.reify(belongs_to: true) }
         | 
| 852 852 |  | 
| 853 853 | 
             
                          should "see the associated as it was the time" do
         | 
| 854 | 
            -
                            assert_nil @ | 
| 854 | 
            +
                            assert_nil @wotsit2.widget
         | 
| 855 855 | 
             
                          end
         | 
| 856 856 | 
             
                        end
         | 
| 857 857 | 
             
                      end
         | 
| @@ -867,10 +867,10 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 867 867 | 
             
                    end
         | 
| 868 868 |  | 
| 869 869 | 
             
                    context "when reified" do
         | 
| 870 | 
            -
                      setup { @ | 
| 870 | 
            +
                      setup { @wotsit0 = @wotsit.versions.last.reify(belongs_to: true) }
         | 
| 871 871 |  | 
| 872 872 | 
             
                      should "see the association as it was at the time" do
         | 
| 873 | 
            -
                        assert_equal "widget_0", @ | 
| 873 | 
            +
                        assert_equal "widget_0", @wotsit0.widget.name
         | 
| 874 874 | 
             
                      end
         | 
| 875 875 |  | 
| 876 876 | 
             
                      should "not persist changes to the live association" do
         | 
| @@ -880,7 +880,7 @@ class AssociationsTest < ActiveSupport::TestCase | |
| 880 880 |  | 
| 881 881 | 
             
                    context "when reified with option mark_for_destruction" do
         | 
| 882 882 | 
             
                      setup do
         | 
| 883 | 
            -
                        @ | 
| 883 | 
            +
                        @wotsit0 = @wotsit.versions.last.
         | 
| 884 884 | 
             
                          reify(belongs_to: true, mark_for_destruction: true)
         | 
| 885 885 | 
             
                      end
         | 
| 886 886 |  |