public
Description: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/technoweenie/attachment_fu.git
Search Repo:
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
Fixed bug from previous commit that wasn't catching nil files uploaded.
Added test case.
redinger (author)
Fri May 09 08:07:24 -0700 2008
commit  6b7bc91a42b058ef175e43f4aa1233bccca4caed
tree    6d52ae9e85b33eca4b2c13331adbe20dad938c81
parent  3836c313d60772ff2ae334083acd083dfdcadf68
...
295
296
297
298
 
299
300
301
...
295
296
297
 
298
299
300
301
0
@@ -295,7 +295,7 @@ module Technoweenie # :nodoc:
0
           self.content_type = file_data.content_type
0
           self.filename = file_data.original_filename if respond_to?(:filename)
0
         else
0
- return nil if file_data.nil? || file_data['size'] == 0
0
+ return nil if file_data.blank? || file_data['size'] == 0
0
           self.content_type = file_data['content_type']
0
           self.filename = file_data['filename']
0
           file_data = file_data['tempfile']
...
67
68
69
 
 
 
 
 
 
 
70
71
...
67
68
69
70
71
72
73
74
75
76
77
78
0
@@ -67,4 +67,11 @@ module BaseAttachmentTests
0
     assert !attachment.save_attachment?
0
     assert_nothing_raised { attachment.save! }
0
   end
0
+
0
+ def test_should_handle_nil_file_upload
0
+ attachment = attachment_model.create :uploaded_data => ''
0
+ assert_raise ActiveRecord::RecordInvalid do
0
+ attachment.save!
0
+ end
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.