public
Description: Rails plugin for easy and rich attachment manipulation.
Clone URL: git://github.com/Manfred/attachment-san.git
Import incoming data handling.

Close temporary file with data coming from StringIO so the file is flushed 
and
we don't have a dangling file pointer. Add failing test for uploads 
through a
tempfile.
Manfred (author)
Fri Jun 20 02:41:38 -0700 2008
commit  0eef1352aa46f9d1e3d61dfb7d6ebe8049c0852b
tree    e1a3b1a9119beb0c15a7b2671068365e41217eec
parent  acb76844d178e34682bab3cf233b3f9ed799a85b
...
18
19
20
 
21
22
23
...
18
19
20
21
22
23
24
0
@@ -18,6 +18,7 @@ module ActiveRecord :nodoc
0
           self.uploaded_file = Tempfile.new(model.filename)
0
           self.uploaded_file.binmode
0
           self.uploaded_file.write data
0
+ self.uploaded_file.close
0
         end
0
       end
0
       
...
11
12
13
14
15
 
 
16
17
18
...
20
21
22
 
 
 
 
 
23
24
25
...
11
12
13
 
 
14
15
16
17
18
...
20
21
22
23
24
25
26
27
28
29
30
0
@@ -11,8 +11,8 @@ describe "Attachment-San" do
0
     File.exist?(attachment.attachment.uploaded_file.path).should == true
0
   end
0
   
0
- it "should handle data coming from CGI when instanciated" do
0
- data = StringIO.new
0
+ it "should handle StringIO data coming from CGI when instanciated" do
0
+ data = StringIO.new('Fake image data')
0
     data.instance_eval do
0
       def content_type; 'image/png'; end
0
       def original_filename; 'rails.png'; end
0
@@ -20,6 +20,11 @@ describe "Attachment-San" do
0
     data << File.read(@rails_icon)
0
     attachment = Attachment.new :uploaded_data => data
0
     File.exist?(attachment.attachment.uploaded_file.path).should == true
0
+ (File.size(attachment.attachment.uploaded_file.path) > 0).should == true
0
+ end
0
+
0
+ it "should handle file data coming from CGI when instanciated" do
0
+ should.flunk 'Implement test'
0
   end
0
   
0
   it "should save the file to the webroot" do

Comments

    No one has commented yet.