diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-23 03:28:55 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-23 03:28:55 +0200 |
| commit | d9e95bdb6436768c738539df74a164c885887174 (patch) | |
| tree | 47b0c461194f3cc9a3194b570f4e077eeccba011 /test/models/node_action_test.rb | |
| parent | dd40bce5ff080885e017709325fb49e9ccd55655 (diff) | |
Add action_participants, recording every node a trash/destroy touches
Diffstat (limited to 'test/models/node_action_test.rb')
| -rw-r--r-- | test/models/node_action_test.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/models/node_action_test.rb b/test/models/node_action_test.rb index b177ccac..849b36f4 100644 --- a/test/models/node_action_test.rb +++ b/test/models/node_action_test.rb | |||
| @@ -118,11 +118,29 @@ class NodeActionTest < ActiveSupport::TestCase | |||
| 118 | 118 | ||
| 119 | test "record! passes provenance and historical timestamps through" do | 119 | test "record! passes provenance and historical timestamps through" do |
| 120 | long_ago = 2.years.ago | 120 | long_ago = 2.years.ago |
| 121 | action = NodeAction.record!(:node => nil, :action => "publish", | 121 | node = Node.root.children.create!(:slug => "provenance_backfill_test") |
| 122 | action = NodeAction.record!(:node => node, :action => "publish", | ||
| 122 | :occurred_at => long_ago, | 123 | :occurred_at => long_ago, |
| 123 | :inferred_from => "from_page_revision") | 124 | :inferred_from => "from_page_revision") |
| 124 | 125 | ||
| 125 | assert_equal "from_page_revision", action.inferred_from | 126 | assert_equal "from_page_revision", action.inferred_from |
| 126 | assert_in_delta long_ago.to_f, action.occurred_at.to_f, 1.0 | 127 | assert_in_delta long_ago.to_f, action.occurred_at.to_f, 1.0 |
| 127 | end | 128 | end |
| 129 | |||
| 130 | |||
| 131 | test "record! with participants: writes one action_participant per subject" do | ||
| 132 | n1, n2 = Node.root.children.create!(:slug => "participant_a"), Node.root.children.create!(:slug => "participant_b") | ||
| 133 | action = NodeAction.record!(:participants => [n1, n2], :action => "trash", :user => users(:quentin)) | ||
| 134 | assert_equal [n1, n2], action.action_participants.map(&:subject) | ||
| 135 | end | ||
| 136 | |||
| 137 | test "record! with node: alone still writes exactly one participant" do | ||
| 138 | node = Node.root.children.create!(:slug => "participant_sugar") | ||
| 139 | action = NodeAction.record!(:node => node, :action => "create", :user => users(:quentin)) | ||
| 140 | assert_equal [node], action.action_participants.map(&:subject) | ||
| 141 | end | ||
| 142 | |||
| 143 | test "record! refuses an empty participant set" do | ||
| 144 | assert_raises(ArgumentError) { NodeAction.record!(:action => "create", :user => users(:quentin)) } | ||
| 145 | end | ||
| 128 | end | 146 | end |
