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

View File

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