@@ -68,7 +68,7 class Attachment < ActiveRecord::Base | |||
|
68 | 68 | |
|
69 | 69 | def validate_max_file_size |
|
70 | 70 | if @temp_file && self.filesize > Setting.attachment_max_size.to_i.kilobytes |
|
71 |
errors.add(:base, |
|
|
71 | errors.add(:base, l(:error_attachment_too_big, :max_size => Setting.attachment_max_size.to_i.kilobytes)) | |
|
72 | 72 | end |
|
73 | 73 | end |
|
74 | 74 |
@@ -116,5 +116,16 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
116 | 116 | assert_response 406 |
|
117 | 117 | end |
|
118 | 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 | 130 | end |
|
120 | 131 | end |
General Comments 0
You need to be logged in to leave comments.
Login now