From 180b5feba092db1339f7bb3217e91f0b22239bc5 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 27 Jul 2026 02:53:21 +0200 Subject: Surface held locks in the dashboard's work-in-progress widget A lock with no draft or autosave behind it was invisible to everyone including its holder, until the next editor collided with it. work_in_progress now admits those nodes, and the widget names the holder rather than the last editor on any locked row. Also flips the ordering to stalest-first, so a backlog reads as a queue rather than a feed, and gives the heading a real total: the count came from the already-limited relation and could never exceed five. --- test/models/node_test.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'test/models/node_test.rb') diff --git a/test/models/node_test.rb b/test/models/node_test.rb index 8bdb90ee..c5b0d6a2 100644 --- a/test/models/node_test.rb +++ b/test/models/node_test.rb @@ -522,17 +522,17 @@ class NodeTest < ActiveSupport::TestCase assert_equal 0, Node.editor_search("Backspace Nonexistentstreet").count end - test "drafts_and_autosaves without a user sorts by recency only" do + test "work_in_progress without a user sorts by oldest-first" do older = Node.root.children.create!(:slug => "drafts_order_older") find_or_create_draft(older, @user1) newer = Node.root.children.create!(:slug => "drafts_order_newer") find_or_create_draft(newer, @user1) - result = Node.drafts_and_autosaves.to_a - assert result.index(newer) < result.index(older) + result = Node.work_in_progress.to_a + assert result.index(older) < result.index(newer) end - test "drafts_and_autosaves with a user puts their own locked nodes first, regardless of recency" do + test "work_in_progress with a user puts their own locked nodes first, regardless of recency" do mine = Node.root.children.create!(:slug => "drafts_order_mine") mine.lock_for_editing!(@user1) mine.autosave!({:title => "mine"}, @user1) @@ -542,10 +542,20 @@ class NodeTest < ActiveSupport::TestCase someone_elses_newer.lock_for_editing!(other_user) someone_elses_newer.autosave!({:title => "theirs"}, other_user) - result = Node.drafts_and_autosaves(current_user_id: @user1.id).to_a + result = Node.work_in_progress(current_user_id: @user1.id).to_a assert result.index(mine) < result.index(someone_elses_newer) end + test "work_in_progress includes a node that is only locked" do + locked = create_node_with_published_page + locked.lock_for_editing!(@user1) + locked.reload + + assert_nil locked.draft + assert_nil locked.autosave + assert_includes Node.work_in_progress.to_a, locked + end + test "autosave! carries over the current related assets to the newly created autosave row" do node = Node.root.children.create!(:slug => "autosave_asset_carryover_test") user = User.find_by_login("quentin") -- cgit v1.3