FIX: only check for conflict on edit drafts

In some unknown cases non edit drafts are being checked for conflict
This commit is contained in:
Sam 2018-11-15 13:14:07 +11:00
parent ee60ecc71f
commit 6556a87629
2 changed files with 7 additions and 3 deletions

View File

@ -12,7 +12,9 @@ class DraftController < ApplicationController
Draft.set(current_user, params[:draft_key], params[:sequence].to_i, params[:data])
if data = JSON::parse(params[:data])
if data["postId"].present? && data["originalText"].present?
# this is a bit of a kludge we need to remove (all the parsing) too many special cases here
# we need to catch action edit and action editSharedDraft
if data["postId"].present? && data["originalText"].present? && data["action"].to_s.start_with?("edit")
post = Post.find_by(id: data["postId"])
if post && post.raw != data["originalText"]
conflict_user = BasicUserSerializer.new(post.last_editor, root: false)

View File

@ -29,7 +29,8 @@ describe DraftController do
sequence: 0,
data: {
postId: post.id,
originalText: post.raw
originalText: post.raw,
action: "edit"
}.to_json
}
@ -41,7 +42,8 @@ describe DraftController do
sequence: 0,
data: {
postId: post.id,
originalText: "something else"
originalText: "something else",
action: "edit"
}.to_json
}