DEV: support script to test concurrent edits

DEV: support script to test concurrent edits

diff --git a/support/fake_writer.rb b/support/fake_writer.rb
new file mode 100644
index 0000000..b8e5ab9
--- /dev/null
+++ b/support/fake_writer.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+require 'fileutils'
+
+Dir.chdir(File.expand_path('../../../..', __FILE__)) do
+
+  require File.expand_path('../../config/environment', __FILE__)
+
+  post_id = ARGV[0].to_i
+
+  if post_id == 0
+    STDERR.puts "Please specify a product id"
+    exit 1
+  end
+
+  puts "Simulating writing on #{post_id}"
+
+  post = Post.find(post_id)
+
+  revisions = %w{
+    the quick brown fox jumped over the lazy fox.
+  }.map { |s| s + " " }
+
+  revisions << { d: revisions.join.length }
+
+  i = 0
+  while true
+    rev = [revisions[i % revisions.length]]
+    ver = SharedEditRevision.where(post_id: post_id).maximum(:version)
+    SharedEditRevision.revise!(post_id: post.id, user_id: 1, client_id: "a", revision: rev, version: ver)
+    sleep(rand * 0.2 + 0.5)
+    print "."
+    i += 1
+  end
+end

GitHub sha: 35a94be9