1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00

Merge pull request #952 from airblade/test_reify_belongs_to_false

Testing reify with belongs_to: false
This commit is contained in:
Jared Beck 2017-04-12 16:53:47 -04:00 committed by GitHub
commit 65f62bc51d
2 changed files with 17 additions and 4 deletions

View file

@ -890,9 +890,6 @@ issues, in order of descending importance.
1. PaperTrail only reifies the first level of associations.
1. [#542](https://github.com/airblade/paper_trail/issues/542) -
Not compatible with [transactional tests][34], aka. transactional fixtures.
1. [#841](https://github.com/airblade/paper_trail/issues/841) -
Without a workaround, reified records cannot be persisted if their associated
records have been deleted.
1. Requires database timestamp columns with fractional second precision.
- Sqlite and postgres timestamps have fractional second precision by default.
[MySQL timestamps do not][35]. Furthermore, MySQL 5.5 and earlier do not

View file

@ -829,7 +829,7 @@ class AssociationsTest < ActiveSupport::TestCase
@widget.destroy
end
context "when reified" do
context "when reified with belongs_to: true" do
setup { @wotsit2 = @wotsit.versions.last.reify(belongs_to: true) }
should "see the associated as it was at the time" do
@ -839,6 +839,22 @@ class AssociationsTest < ActiveSupport::TestCase
should "not persist changes to the live association" do
assert_nil @wotsit.reload.widget
end
should "be able to persist the reified record" do
assert_nothing_raised { @wotsit2.save! }
end
end
context "when reified with belongs_to: false" do
setup do
@wotsit2 = @wotsit.versions.last.reify(belongs_to: false)
end
should "save should not re-create the widget record" do
# Save succeeds because Wotsit does not validate presence of widget
@wotsit2.save!
assert_nil ::Widget.find_by(id: @widget.id)
end
end
context "and then the model is updated" do