Backported r9982 and r9984 from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@10000 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-07-15 16:00:58 +00:00
parent 75e350f4e6
commit dbc02e66dc
5 changed files with 10 additions and 1 deletions

View 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, :allow_blank => true
validate :validate_max_file_size
acts_as_event :title => :filename,

View File

@@ -10,7 +10,7 @@
<span>
<%= file_field_tag 'attachments[1][file]', :size => 30, :id => nil, :class => 'file',
:onchange => "checkFileSize(this, #{Setting.attachment_max_size.to_i.kilobytes}, '#{escape_javascript(l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)))}');" -%>
<%= text_field_tag 'attachments[1][description]', '', :id => nil, :class => 'description', :placeholder => l(:label_optional_description) %>
<%= text_field_tag 'attachments[1][description]', '', :id => nil, :class => 'description', :maxlength => 255, :placeholder => l(:label_optional_description) %>
<%= link_to_function(image_tag('delete.png'), 'removeFileField(this)', :title => (l(:button_delete))) %>
</span>
</span>

View File

@@ -8,6 +8,7 @@ http://www.redmine.org/
* Defect #11192: Make repository identifier accept underscores
* Defect #11307: Can't filter for negative numeric custom fields
* Defect #11365: Attachment description length is not validated
* Feature #11338: Exclude emails with auto-submitted => auto-generated
* Patch #11328: Fix Japanese mistranslation for 'label_language_based'

View File

@@ -1305,6 +1305,7 @@ class IssuesControllerTest < ActionController::TestCase
:tag => 'input',
:attributes => {:type => 'file', :name => 'attachments[1][file]'}
}
assert_select 'input[name=?][maxlength=255]', 'attachments[1][description]'
end
def test_get_new_should_prefill_the_form_from_params

View 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"),