diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 02:03:19 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 02:03:19 +0200 |
| commit | 205e6216fc7850fe717122c189e5003d1f9e8afe (patch) | |
| tree | 8627354f3577f0a974949e759b0e93662840ade7 /test/models | |
| parent | 81769557804ce59ce3e4603e8f47e731b61b180d (diff) | |
Add head/draft/autosave layer comparison at three UI entry points
Node#resolve_page_reference and #available_layer_pairs let
Page#diff_against compare named layers (head/draft/autosave), not
just numbered revisions -- autosave was never part of Node#pages, so
this was the missing piece.
Wired into nodes#show's Status section, nodes#edit right after an
autosave gets resurrected ("What changed?"), and the admin wizard's
current-drafts table, which now also lists autosave-only nodes it
previously never showed.
revisions#diff hides the numbered-revision picker when comparing
named layers (it can't represent them), shows a plain label instead,
and offers buttons to switch between whichever other pairs make
sense for the node's current state. Destroying the topmost layer is
available directly from the diff view, reusing the existing revert!
path.
"Discard changes" is renamed "Discard Autosave" everywhere it
appears, to match "Destroy Draft".
Diffstat (limited to 'test/models')
| -rw-r--r-- | test/models/node_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/models/node_test.rb b/test/models/node_test.rb index 2138c19..9e71dec 100644 --- a/test/models/node_test.rb +++ b/test/models/node_test.rb | |||
| @@ -473,4 +473,26 @@ class NodeTest < ActiveSupport::TestCase | |||
| 473 | node.publish_draft! | 473 | node.publish_draft! |
| 474 | end | 474 | end |
| 475 | end | 475 | end |
| 476 | |||
| 477 | test "available_layer_pairs matches the six-state table" do | ||
| 478 | node = Node.root.children.create!(:slug => "layer_pairs_test") | ||
| 479 | user = @user1 || User.find_by_login("aaron") | ||
| 480 | |||
| 481 | assert_equal [[:draft, :autosave]], (node.lock_for_editing!(user); node.autosave!({title: "v1"}, user); node.available_layer_pairs) # state F | ||
| 482 | |||
| 483 | node.save_draft!(user) | ||
| 484 | node.publish_draft! | ||
| 485 | assert_equal [], node.available_layer_pairs # state A | ||
| 486 | |||
| 487 | node.lock_for_editing!(user) | ||
| 488 | node.autosave!({title: "v2"}, user) | ||
| 489 | assert_equal [[:head, :autosave]], node.available_layer_pairs # state B | ||
| 490 | |||
| 491 | node.save_draft!(user) | ||
| 492 | assert_equal [[:head, :draft]], node.available_layer_pairs # state C | ||
| 493 | |||
| 494 | node.lock_for_editing!(user) | ||
| 495 | node.autosave!({title: "v3"}, user) | ||
| 496 | assert_equal [[:head, :draft], [:draft, :autosave]], node.available_layer_pairs # state D | ||
| 497 | end | ||
| 476 | end | 498 | end |
