inline_forms_installer 8.1.16 → 8.1.17
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c46819a2ebdd8fc0e78bf6552f9ad15e07f32683c11c9e0c36c8461a2b3e53f7
|
|
4
|
+
data.tar.gz: 488a04adfc5490222bbeb037e302bc11cb229b60002b88e384de26ac2aa1d562
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a64cb19004014e639af9a1c3bb6cbec783521929fc36b5f50f782f21f622db5402e2c45210a08cb2744301e2d1d54b3479c146cc465b266c6ea337918881f809
|
|
7
|
+
data.tar.gz: 862b03e84c8b8627bbd55ac2611e87da3bc0c20979d6d4755642967503b01e3861607caa5fdc594ea58e3aab4e47800a2a13861501392ed1bbfd90d36fecb133
|
|
@@ -93,4 +93,42 @@ class ExampleAppPhotosTest < ExampleAppIntegrationTestCase
|
|
|
93
93
|
).count
|
|
94
94
|
assert_includes Photo.find(photo_id).description.body.to_html, "Twice undo"
|
|
95
95
|
end
|
|
96
|
+
|
|
97
|
+
# Regression: PaperTrail records a non-empty changeset for `destroy` events,
|
|
98
|
+
# so the versions panel shows a Restore link on `destroy` rows. Reverting a
|
|
99
|
+
# `destroy` reifies a record with the original PK and `new_record? == true`.
|
|
100
|
+
# Once the row has already been restored (undone), the old `@parent.save!`
|
|
101
|
+
# re-INSERTed that PK -> `RecordNotUnique` (`UNIQUE constraint failed:
|
|
102
|
+
# photos.id`). Revert must be idempotent: restoring a `destroy` version while
|
|
103
|
+
# the row exists updates it in place instead of crashing.
|
|
104
|
+
test "restoring a destroy version while the photo exists does not raise RecordNotUnique" do
|
|
105
|
+
photo = @apartment.photos.create!(name: "restore.jpg", caption: "before")
|
|
106
|
+
photo.update!(caption: "after")
|
|
107
|
+
photo_id = photo.id
|
|
108
|
+
|
|
109
|
+
row_frame = "apartment_#{@apartment.id}_photo_#{photo_id}"
|
|
110
|
+
row_headers = { "Turbo-Frame" => row_frame, "Accept" => "text/html" }
|
|
111
|
+
stream_headers = row_headers.merge("Accept" => "text/vnd.turbo-stream.html")
|
|
112
|
+
|
|
113
|
+
delete photo_path(photo, update: row_frame), headers: row_headers
|
|
114
|
+
assert_response :success
|
|
115
|
+
|
|
116
|
+
destroy_version = PaperTrail::Version.where(
|
|
117
|
+
item_type: "Photo",
|
|
118
|
+
item_id: photo_id,
|
|
119
|
+
event: "destroy"
|
|
120
|
+
).order(:id).last
|
|
121
|
+
assert destroy_version, "expected a Photo destroy version"
|
|
122
|
+
|
|
123
|
+
post revert_photo_path(destroy_version, update: row_frame), headers: stream_headers
|
|
124
|
+
assert_response :success
|
|
125
|
+
assert Photo.exists?(photo_id), "undo should have restored the photo row"
|
|
126
|
+
|
|
127
|
+
# The row now exists again. Restoring the SAME destroy version (panel
|
|
128
|
+
# Restore link, or a replayed undo) must not INSERT a duplicate id.
|
|
129
|
+
post revert_photo_path(destroy_version, update: row_frame), headers: stream_headers
|
|
130
|
+
assert_response :success,
|
|
131
|
+
"restoring a destroy version while the row exists must not raise RecordNotUnique"
|
|
132
|
+
assert_equal 1, Photo.where(id: photo_id).count
|
|
133
|
+
end
|
|
96
134
|
end
|