For deleted nodes created via factories, make sure the most recent old_node is also...
authorAndy Allan <git@gravitystorm.co.uk>
Thu, 30 Mar 2017 12:57:07 +0000 (13:57 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Thu, 30 Mar 2017 12:57:07 +0000 (13:57 +0100)
test/factories/node.rb

index 1d8e244..cbebbb0 100644 (file)
@@ -18,6 +18,13 @@ FactoryGirl.define do
         (1..node.version).each do |n|
           create(:old_node, :node_id => node.id, :version => n)
         end
+
+        # For deleted nodes, make sure the most recent old_node is also deleted.
+        if node.visible == false
+          latest = node.old_nodes.find_by(:version => node.version)
+          latest.visible = false
+          latest.save
+        end
       end
     end
   end