summaryrefslogtreecommitdiff
path: root/test/models/node_action_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/models/node_action_test.rb')
-rw-r--r--test/models/node_action_test.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/models/node_action_test.rb b/test/models/node_action_test.rb
index b177cca..849b36f 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
128end 146end