Skip to content

Commit

Permalink
error if parent comment was removed during writing
Browse files Browse the repository at this point in the history
  • Loading branch information
pushcx committed Nov 30, 2018
1 parent 1c82243 commit 5b958d9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Comment < ApplicationRecord
self.story_id.blank? &&
errors.add(:story_id, "cannot be blank.")

self.parent_comment && self.parent_comment.is_gone? &&
errors.add(:base, "Comment was deleted by the author or a mod while you were writing.")

(m = self.comment.to_s.strip.match(/\A(t)his([\.!])?$\z/i)) &&
errors.add(:base, (m[1] == "T" ? "N" : "n") + "ope" + m[2].to_s)

Expand Down

0 comments on commit 5b958d9

Please sign in to comment.