def validate_max_file_size
if @temp_file && self.filesize > Setting.attachment_max_size.to_i.kilobytes
- errors.add(:base, :too_long, :count => Setting.attachment_max_size.to_i.kilobytes)
+ errors.add(:base, l(:error_attachment_too_big, :max_size => Setting.attachment_max_size.to_i.kilobytes))
end
end
assert_response 406
end
end
+
+ should "return errors if file is too big" do
+ set_tmp_attachments_directory
+ with_settings :attachment_max_size => 1 do
+ assert_no_difference 'Attachment.count' do
+ post '/uploads.xml', ('x' * 2048), {'Content-Type' => 'application/octet-stream'}.merge(credentials('jsmith'))
+ assert_response 422
+ assert_tag 'error', :content => /exceeds the maximum allowed file size/
+ end
+ end
+ end
end
end