##// END OF EJS Templates
Better message for file size validation error....
Jean-Philippe Lang -
r8817:7e347069d560
parent child
Show More
@@ -68,7 +68,7 class Attachment < ActiveRecord::Base
68
68
69 def validate_max_file_size
69 def validate_max_file_size
70 if @temp_file && self.filesize > Setting.attachment_max_size.to_i.kilobytes
70 if @temp_file && self.filesize > Setting.attachment_max_size.to_i.kilobytes
71 errors.add(:base, :too_long, :count => Setting.attachment_max_size.to_i.kilobytes)
71 errors.add(:base, l(:error_attachment_too_big, :max_size => Setting.attachment_max_size.to_i.kilobytes))
72 end
72 end
73 end
73 end
74
74
@@ -116,5 +116,16 class ApiTest::AttachmentsTest < ActionController::IntegrationTest
116 assert_response 406
116 assert_response 406
117 end
117 end
118 end
118 end
119
120 should "return errors if file is too big" do
121 set_tmp_attachments_directory
122 with_settings :attachment_max_size => 1 do
123 assert_no_difference 'Attachment.count' do
124 post '/uploads.xml', ('x' * 2048), {'Content-Type' => 'application/octet-stream'}.merge(credentials('jsmith'))
125 assert_response 422
126 assert_tag 'error', :content => /exceeds the maximum allowed file size/
127 end
128 end
129 end
119 end
130 end
120 end
131 end
General Comments 0
You need to be logged in to leave comments. Login now