]> source.dussan.org Git - redmine.git/commitdiff
Fixes that custom values length and attachment size validation error raises an error.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 8 Apr 2009 16:56:01 +0000 (16:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 8 Apr 2009 16:56:01 +0000 (16:56 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2667 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/attachment.rb
app/models/custom_value.rb

index 2957b9dd17a8fbea4b24060f9d019170e1ff3b30..bffd64bf9d31318d0407539cbea6a33f30225744 100644 (file)
@@ -46,7 +46,9 @@ class Attachment < ActiveRecord::Base
   @@storage_path = "#{RAILS_ROOT}/files"
   
   def validate
-    errors.add_to_base :too_long if self.filesize > Setting.attachment_max_size.to_i.kilobytes
+    if self.filesize > Setting.attachment_max_size.to_i.kilobytes
+      errors.add(:base, :too_long, :count => Setting.attachment_max_size.to_i.kilobytes)
+    end
   end
 
   def file=(incoming_file)
index 2d7d1cffec801fc2cdd8b2e690d9de75e41bb672..4cace724ad041fa442d0101b24e52122d63331d1 100644 (file)
@@ -48,8 +48,8 @@ protected
       errors.add(:value, :blank) if custom_field.is_required? and value.blank?    
     else
       errors.add(:value, :invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
-      errors.add(:value, :too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length
-      errors.add(:value, :too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length
+      errors.add(:value, :too_short, :count => custom_field.min_length) if custom_field.min_length > 0 and value.length < custom_field.min_length
+      errors.add(:value, :too_long, :count => custom_field.max_length) if custom_field.max_length > 0 and value.length > custom_field.max_length
     
       # Format specific validations
       case custom_field.field_format