@@ -24,6 +24,7 class Attachment < ActiveRecord::Base | |||||
24 | validates_presence_of :filename, :author |
|
24 | validates_presence_of :filename, :author | |
25 | validates_length_of :filename, :maximum => 255 |
|
25 | validates_length_of :filename, :maximum => 255 | |
26 | validates_length_of :disk_filename, :maximum => 255 |
|
26 | validates_length_of :disk_filename, :maximum => 255 | |
|
27 | validates_length_of :description, :maximum => 255 | |||
27 | validate :validate_max_file_size |
|
28 | validate :validate_max_file_size | |
28 |
|
29 | |||
29 | acts_as_event :title => :filename, |
|
30 | acts_as_event :title => :filename, |
@@ -75,6 +75,12 class AttachmentTest < ActiveSupport::TestCase | |||||
75 | end |
|
75 | end | |
76 | end |
|
76 | end | |
77 |
|
77 | |||
|
78 | def test_description_length_should_be_validated | |||
|
79 | a = Attachment.new(:description => 'a' * 300) | |||
|
80 | assert !a.save | |||
|
81 | assert_not_nil a.errors[:description] | |||
|
82 | end | |||
|
83 | ||||
78 | def test_destroy |
|
84 | def test_destroy | |
79 | a = Attachment.new(:container => Issue.find(1), |
|
85 | a = Attachment.new(:container => Issue.find(1), | |
80 | :file => uploaded_test_file("testfile.txt", "text/plain"), |
|
86 | :file => uploaded_test_file("testfile.txt", "text/plain"), |
General Comments 0
You need to be logged in to leave comments.
Login now