diff --git a/app/models/post.rb b/app/models/post.rb index 7aa9155264a..3f97171bb79 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -63,6 +63,7 @@ class Post < ActiveRecord::Base has_many :post_hotlinked_media, dependent: :destroy, class_name: "PostHotlinkedMedia" validates_with PostValidator, unless: :skip_validation + validates :edit_reason, length: { maximum: 1000 } after_commit :index_search diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index deb5e637f9e..d4327035441 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -57,6 +57,7 @@ RSpec.describe Post do end it { is_expected.to validate_presence_of :raw } + it { is_expected.to validate_length_of(:edit_reason).is_at_most(1000) } # Min/max body lengths, respecting padding it { is_expected.not_to allow_value("x").for(:raw) }