FIX: don't create a new revision when there was an error while saving the post and/or topic

This commit is contained in:
Régis Hanol 2014-11-03 15:31:11 +01:00
parent b09ad87098
commit 52b3877b70
2 changed files with 9 additions and 17 deletions

View file

@ -101,9 +101,6 @@ class PostDestroyer
@post.update_flagged_posts_count
@post.topic_links.each(&:destroy)
end
# covered by PostRevisor
# @post.publish_change_to_clients! :revised
end
def user_recovered
@ -113,9 +110,6 @@ class PostDestroyer
@post.revise(@user, { raw: @post.revisions.last.modifications["raw"][0] }, force_new_version: true)
@post.update_flagged_posts_count
end
# covered by PostRevisor
# @post.publish_change_to_clients! :revised
end

View file

@ -67,7 +67,7 @@ class PostRevisor
publish_changes
grant_badge
@post_successfully_saved && @topic_successfully_saved
successfully_saved_post_and_topic
end
def cleanup_whitespaces(raw)
@ -93,11 +93,7 @@ class PostRevisor
end
def revise_post
if should_create_new_version?
revise_and_create_new_version
else
revise
end
should_create_new_version? ? revise_and_create_new_version : revise
end
def should_create_new_version?
@ -178,11 +174,9 @@ class PostRevisor
end
def create_or_update_revision
if @version_changed
create_revision
else
update_revision
end
# don't create an empty revision if something failed
return unless successfully_saved_post_and_topic
@version_changed ? create_revision : update_revision
end
def create_revision
@ -305,4 +299,8 @@ class PostRevisor
BadgeGranter.queue_badge_grant(Badge::Trigger::PostRevision, post: @post)
end
def successfully_saved_post_and_topic
@post_successfully_saved && @topic_successfully_saved
end
end