inline_forms_installer 8.1.15 → 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: d5f4f62e8dc739c6bcde28ecb37ec09d51d96fb26083bdf7d6f5b2e0728fe118
4
- data.tar.gz: 577d7275a99ed7089d373a87da0e271c24c2910054f81350f0777296a99860c4
3
+ metadata.gz: c46819a2ebdd8fc0e78bf6552f9ad15e07f32683c11c9e0c36c8461a2b3e53f7
4
+ data.tar.gz: 488a04adfc5490222bbeb037e302bc11cb229b60002b88e384de26ac2aa1d562
5
5
  SHA512:
6
- metadata.gz: 91383e851c360f5e93ee24175c6b8f9f7bc5eb4ca9163ab167335a1c803ed054c8daa8c723e7576b586e4a03f3250411b6cc4321446ca48d0b034e8ad2d50128
7
- data.tar.gz: 479e0d53b0c2531a32c943cb7c8e5350ec8b0611c3281b6bd3147b94760e3d2eaa6df6bfc6b3c649a844bf8235f682af136688091fb954b0b4c8bab3fc0663cf
6
+ metadata.gz: a64cb19004014e639af9a1c3bb6cbec783521929fc36b5f50f782f21f622db5402e2c45210a08cb2744301e2d1d54b3479c146cc465b266c6ea337918881f809
7
+ data.tar.gz: 862b03e84c8b8627bbd55ac2611e87da3bc0c20979d6d4755642967503b01e3861607caa5fdc594ea58e3aab4e47800a2a13861501392ed1bbfd90d36fecb133
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineFormsInstaller
3
- VERSION = "8.1.15"
3
+ VERSION = "8.1.17"
4
4
 
5
5
  # Written into generated apps' `.ruby-version` (must match gemspec `required_ruby_version`).
6
6
  TARGET_RUBY_VERSION = "ruby-4.0.4"
@@ -53,4 +53,82 @@ class ExampleAppPhotosTest < ExampleAppIntegrationTestCase
53
53
  assert_response :success
54
54
  assert_includes Photo.find(photo_id).description.body.to_html, "survives undo"
55
55
  end
56
+
57
+ test "nested photo delete undo twice does not duplicate ActionText rows" do
58
+ photo = @apartment.photos.create!(name: "twice.jpg", caption: "c")
59
+ body = "<p>Twice undo description</p>"
60
+ field_frame = "apartment_#{@apartment.id}_photo_#{photo.id}_description"
61
+ put photo_path(
62
+ photo,
63
+ attribute: "description",
64
+ form_element: "rich_text",
65
+ update: field_frame
66
+ ), params: { description: body },
67
+ headers: { "Turbo-Frame" => field_frame, "Accept" => "text/html" }
68
+
69
+ photo_id = photo.id
70
+ row_frame = "apartment_#{@apartment.id}_photo_#{photo_id}"
71
+ row_headers = { "Turbo-Frame" => row_frame, "Accept" => "text/html" }
72
+ stream_headers = row_headers.merge("Accept" => "text/vnd.turbo-stream.html")
73
+
74
+ 2.times do
75
+ delete photo_path(Photo.find(photo_id), update: row_frame), headers: row_headers
76
+ assert_response :success
77
+
78
+ destroy_version = PaperTrail::Version.where(
79
+ item_type: "Photo",
80
+ item_id: photo_id,
81
+ event: "destroy"
82
+ ).order(:id).last
83
+ post revert_photo_path(destroy_version, update: row_frame), headers: stream_headers
84
+ assert_response :success,
85
+ "second delete/undo must not INSERT a duplicate action_text_rich_texts id"
86
+ end
87
+
88
+ assert_equal 1,
89
+ ActionText::RichText.where(
90
+ record_type: "Photo",
91
+ record_id: photo_id,
92
+ name: "description"
93
+ ).count
94
+ assert_includes Photo.find(photo_id).description.body.to_html, "Twice undo"
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
56
134
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms_installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.15
4
+ version: 8.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares