Limit revision's description text length

This commit is contained in:
Karel Picman 2018-01-09 15:38:15 +01:00
parent 5b85416d79
commit d5448267be
2 changed files with 8 additions and 0 deletions

View File

@ -55,6 +55,7 @@ class DmsfFileRevision < ActiveRecord::Base
validates :title, :presence => true
validates_format_of :name, :with => DmsfFolder::INVALID_CHARACTERS,
:message => l(:error_contains_invalid_character)
validates :description, length: { maximum: 1.megabyte }
def project
self.dmsf_file.project if self.dmsf_file

View File

@ -210,4 +210,11 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
assert_equal -(' '.ord), @revision1.minor_version
end
def description_max_length
@revision1.description = 2.megabytes * 'a'
assert !@revision1.save
@revision1.description = 1.megabyte * 'a'
assert @revision1.save
end
end