FIX: Explicit error when category description post is bad

This commit is contained in:
Rafael dos Santos Silva
2017-07-21 16:07:29 -03:00
parent 62604e9297
commit 89ef5d36a9
3 changed files with 24 additions and 5 deletions

View File

@@ -442,11 +442,13 @@ class PostRevisor
doc = Nokogiri::HTML.fragment(@post.cooked)
doc.css("img").remove
html = doc.css("p").first.inner_html.strip
new_description = html unless html.starts_with?(Category.post_template[0..50])
category.update_column(:description, new_description)
@category_changed = category
if html = doc.css("p").first&.inner_html&.strip
new_description = html unless html.starts_with?(Category.post_template[0..50])
category.update_column(:description, new_description)
@category_changed = category
else
@post.errors[:base] << I18n.t("category.errors.description_incomplete")
end
end
def advance_draft_sequence