]> source.dussan.org Git - redmine.git/commitdiff
Validate attachment description length (#11365).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jul 2012 14:42:00 +0000 (14:42 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jul 2012 14:42:00 +0000 (14:42 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9984 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/attachment.rb
test/unit/attachment_test.rb

index 1fd0a5b82e640e8759c150c6ba0946e184246619..0dda33023b1d1b3c79122e386b5aec40014e240f 100644 (file)
@@ -24,6 +24,7 @@ class Attachment < ActiveRecord::Base
   validates_presence_of :filename, :author
   validates_length_of :filename, :maximum => 255
   validates_length_of :disk_filename, :maximum => 255
+  validates_length_of :description, :maximum => 255
   validate :validate_max_file_size
 
   acts_as_event :title => :filename,
index cd301dc9384f19e2459a0004dc23b816a5c96da1..c2a3e56b44ad6e1c66351f1a898f4a1db8ca3f3f 100644 (file)
@@ -75,6 +75,12 @@ class AttachmentTest < ActiveSupport::TestCase
     end
   end
 
+  def test_description_length_should_be_validated
+    a = Attachment.new(:description => 'a' * 300)
+    assert !a.save
+    assert_not_nil a.errors[:description]
+  end
+
   def test_destroy
     a = Attachment.new(:container => Issue.find(1),
                        :file => uploaded_test_file("testfile.txt", "text/plain"),