diff --git a/lib/active_snapshot/models/concerns/snapshots_concern.rb b/lib/active_snapshot/models/concerns/snapshots_concern.rb index 217945f..50fe95e 100644 --- a/lib/active_snapshot/models/concerns/snapshots_concern.rb +++ b/lib/active_snapshot/models/concerns/snapshots_concern.rb @@ -34,7 +34,7 @@ def create_snapshot!(identifier: nil, user: nil, metadata: nil) SnapshotItem.upsert_all(new_entries.map{|x| x.delete("id"); x }, returning: false) - snapshot + snapshot.reload end class_methods do diff --git a/test/models/snapshots_concern_test.rb b/test/models/snapshots_concern_test.rb index 5950d5e..ea281ed 100644 --- a/test/models/snapshots_concern_test.rb +++ b/test/models/snapshots_concern_test.rb @@ -37,6 +37,7 @@ def test_create_snapshot! snapshot = @post.create_snapshot!(identifier: "foobar 1", user: @user, metadata: {foo: :bar}) assert_not snapshot.new_record? + assert snapshot.valid? snapshot = @post.create_snapshot!(identifier: "foobar 2", user: @user) assert_not snapshot.new_record?