inline_forms 8.1.13 → 8.1.16

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: 5ae9fa81e904412a8066f7b989cc62d751ecd2ec388e86280a9f29c40c71066c
4
- data.tar.gz: a1ef139cf1a6ab1827a79dfe4b13b83cc106dbaf4618f3840a4f00c623139d30
3
+ metadata.gz: a523b9082f8bf1ada004984c1d3cc66e745cae0e525e36acbf66df97b7015e98
4
+ data.tar.gz: d82f9950bde7f293ea70ef2e63162bcb304a0fac44eb6c8f645f88bbefe947da
5
5
  SHA512:
6
- metadata.gz: 87a7b60dbc16267a2b1415374747785df190d82fb00d9df751dd6b3c47e9f02a82e2d2127ff04784fe659d6709ffd64044952c013c11fc49af0bad47284a29c7
7
- data.tar.gz: 4452500f6fa5b2e6f1010a61e3a5f30ba755b44de4861a09868787136a4f06aa4873d545b03e68af782d0239bd8d55289c60cbdce22fde565d26d4ccda24a28f
6
+ metadata.gz: 275bec7794f426e5131ae69843dfcb9bd2cec55ae9124075bc59ae0e171fc6df3d406ae776d78526a918a12dbc87aa41b0b12ade138fd4f520d75254570e6b01
7
+ data.tar.gz: 33bb93de6e2f017d664b610e07105afea73708b5ee67a269b48bd68de6b3d0fa8b9688eab4c21882ea408a8fc7ab68fcf6e2a18ff733d56fad29110e5863790e
data/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@ All notable changes to this project are documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [8.1.16] - 2026-05-28
8
+
9
+ ### Fixed
10
+
11
+ - **`RecordNotUnique` on `action_text_rich_texts.id` when undoing a delete more than once.** Restoring rich text after parent undo used `reify.save!`, which INSERTs the old primary key. A second delete/undo cycle (or an already-restored row) hit SQLite's unique constraint. Restoration now upserts by `(record_type, record_id, name)` and copies `body` only, and only the latest PaperTrail `destroy` version per attribute is applied.
12
+
13
+ ### Added
14
+
15
+ - **Regression test:** nested Photo delete → undo → delete → undo.
16
+
17
+ ## [8.1.15] - 2026-05-28
18
+
19
+ ### Fixed
20
+
21
+ - **Post-delete undo on Apartment/Photo (and any model with `rich_text`) left `description` empty.** Undo only reified the parent row; ActionText bodies live in `action_text_rich_texts` and are removed on `destroy`, with separate PaperTrail `destroy` versions. `revert` now also reifies and saves each `ActionText::RichText` destroy snapshot that belonged to the restored parent (Apartment, nested Photo, `FormElementShowcase#description`, etc.).
22
+
23
+ ### Added
24
+
25
+ - **Regression tests:** apartment row destroy+undo with `description` rich text; nested photo destroy+undo with `description` rich text.
26
+
27
+ ## [8.1.14] - 2026-05-28
28
+
29
+ ### Fixed
30
+
31
+ - **`example_app_showcase_row_turbo_test` broke `--example` installs.** The Empty-demo undo regression parsed the undo URL as `/revert/:id`, but member routes are `/form_element_showcases/:id/revert`. The installer gate failed (`131 runs, 1 failure`) and surfaced the misleading “Rails could not create the app 'MyApp', maybe because it is a reserved word…” message even though the app was generated. The test now matches the real path and loads the destroy version from PaperTrail.
32
+
7
33
  ## [8.1.13] - 2026-05-28
8
34
 
9
35
  ### Fixed
@@ -320,12 +320,63 @@ class InlineFormsController < ApplicationController
320
320
  else
321
321
  @parent = @object
322
322
  @parent.save!
323
+ restore_rich_texts_for_reverted_parent!(@parent)
324
+ @parent.reload
323
325
  end
324
326
  render_revert_response if row_html_turbo_allowed?
325
327
  end
326
328
 
327
329
  private
328
330
 
331
+ # Undoing a parent +destroy+ reifies the Apartment/Photo row only. ActionText
332
+ # bodies live in +action_text_rich_texts+ and get their own PaperTrail
333
+ # +destroy+ versions; those rows are gone after +parent.destroy+, so we also
334
+ # reify each matching +ActionText::RichText+ destroy snapshot.
335
+ #
336
+ # Use +find_or_initialize_by(record_type, record_id, name)+ and copy +body+
337
+ # only. Reified rows carry the old PK; +save!+ on a new record would INSERT
338
+ # that id and raise +RecordNotUnique+ on a second delete/undo cycle when the
339
+ # row already exists. Only the newest destroy version per attribute name is
340
+ # applied (repeat delete/undo leaves multiple RT destroy versions in the table).
341
+ def restore_rich_texts_for_reverted_parent!(parent)
342
+ return unless defined?(ActionText::RichText)
343
+
344
+ record_type = parent.class.base_class.name
345
+ record_id = parent.id
346
+ versions_by_name = {}
347
+
348
+ PaperTrail::Version
349
+ .where(item_type: "ActionText::RichText", event: "destroy")
350
+ .order(id: :desc)
351
+ .each do |version|
352
+ attrs = version.object_deserialized
353
+ next unless attrs.is_a?(Hash)
354
+
355
+ type = attrs["record_type"] || attrs[:record_type]
356
+ rid = attrs["record_id"] || attrs[:record_id]
357
+ next unless type == record_type && rid.to_i == record_id
358
+
359
+ name = (attrs["name"] || attrs[:name]).to_s
360
+ next if name.empty?
361
+
362
+ versions_by_name[name] ||= version
363
+ end
364
+
365
+ versions_by_name.each_value do |version|
366
+ reified = version.reify
367
+ next unless reified
368
+
369
+ name = reified.name.to_s
370
+ record = ActionText::RichText.find_or_initialize_by(
371
+ record_type: record_type,
372
+ record_id: record_id,
373
+ name: name
374
+ )
375
+ record.body = reified.body if reified.respond_to?(:body)
376
+ record.save!
377
+ end
378
+ end
379
+
329
380
  # +revert+ is excluded from +load_and_authorize_resource+; +authorize!+ runs in the
330
381
  # action. +check_authorization+ on ApplicationController still requires that flag.
331
382
  def revert_authorization_subject(version)
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "8.1.13"
3
+ VERSION = "8.1.16"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.13
4
+ version: 8.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares