bli/paper_trail — pull request #1 by batter (2014-12-11 01:26:24+00:00)
Title: Add some test cases showing issues with reification of has_one's

@bli - I am still seeing issues where doing a `version.reify(:has_one => true)` ends up persisting changes to the live objects. Here are some test cases showing what I'm talking about. In fact, it seems to orphan the live associated object(s):

```ruby
$ rails c
> w = Widget.create!(name: 'foobar')
=> #
> w.create_wotsit
=> #
> w.wotsit.update_attribute(:name, 'foo')
=> true
> w.update_attributes(name: 'goofie')
=> true
> w.versions.last.reify(has_one: true)
# here is the sql print out in the console:
PaperTrail::Version Load (0.1ms) SELECT "versions".* FROM "versions" WHERE "versions"."item_id" = ? AND "versions"."item_type" = ? ORDER BY "versions"."created_at" DESC, "versions"."id" DESC LIMIT 1 [["item_id", 1], ["item_type", "Widget"]]
Widget Load (0.1ms) SELECT "widgets".* FROM "widgets" WHERE "widgets"."id" = ? LIMIT 1 [["id", 1]]
PaperTrail::Version Load (0.2ms) SELECT "versions".* FROM "versions" INNER JOIN "version_associations" ON "version_associations"."version_id" = "versions"."id" WHERE (version_associations.foreign_key_name = 'widget_id') AND (version_associations.foreign_key_id = 1) AND (versions.item_type = 'Wotsit') AND (created_at >= '2014-12-11 00:54:07.572095' OR transaction_id = 1) ORDER BY versions.id ASC LIMIT 1
Wotsit Load (0.0ms) SELECT "wotsits".* FROM "wotsits" WHERE "wotsits"."widget_id" = ? LIMIT 1 [["widget_id", 1]]
(0.0ms) SAVEPOINT active_record_1
SQL (0.1ms) UPDATE "wotsits" SET "updated_at" = ?, "widget_id" = ? WHERE "wotsits"."id" = 1 [["updated_at", "2014-12-11 00:54:47.810704"], ["widget_id", nil]]
SQL (0.1ms) INSERT INTO "versions" ("created_at", "event", "item_id", "item_type", "object", "object_changes", "transaction_id") VALUES (?, ?, ?, ?, ?, ?, ?) [["created_at", "2014-12-11 00:54:47.810704"], ["event", "update"], ["item_id", 1], ["item_type", "Wotsit"], ["object", "---\nid: 1\nwidget_id: 1\nname: foo\ncreated_at: 2014-12-11 00:53:51.460275000 Z\nupdated_at: 2014-12-11 00:54:17.210878000 Z\n"], ["object_changes", "---\nwidget_id:\n- 1\n- \nupdated_at:\n- 2014-12-11 00:54:17.210878000 Z\n- 2014-12-11 00:54:47.810704000 Z\n"], ["transaction_id", 1]]
SQL (0.1ms) INSERT INTO "version_associations" ("foreign_key_name", "version_id") VALUES (?, ?) [["foreign_key_name", "widget_id"], ["version_id", 5]]
(0.0ms) RELEASE SAVEPOINT active_record_1
=> #
> w.wotsit(true)
=> nil
> Wotsit.count
=> 1
> Wotsit.first
=> #
```

So as you can see, it seems to orphan the existing live `Wotsit` associated to the live `Widget`. For some reason it seems to set the `wotsit.widget_id` to `nil`, as can be seen in the SQL printout above. We can't have the `reify` method making updates to the live objects in the DB.