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
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
change #process_attachment to an after_validation callback

git-svn-id: 
http://svn.techno-weenie.net/projects/plugins/attachment_fu@2654 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Jan 10 18:05:27 -0800 2007
commit  e279f106b4a05cc89e8d246fc72875f6a651b1c5
tree    45be4417406677e6f73bb4bcb29e2c1e7c8aec2c
parent  d35205c97b2ff49922ec2be824c0b6b9957b76ed
...
78
79
80
81
 
82
83
84
...
78
79
80
 
81
82
83
84
0
@@ -78,7 +78,7 @@ module Technoweenie # :nodoc:
0
             else
0
               include Technoweenie::AttachmentFu::Processors.const_get("#{options[:processor].to_s.classify}")
0
           end
0
- before_save :process_attachment
0
+ after_validation :process_attachment
0
         end
0
         
0
         options[:content_type] = [options[:content_type]].flatten.collect { |t| t == :image ? Technoweenie::AttachmentFu.content_types : t }.flatten unless options[:content_type].nil?
...
47
48
49
 
 
 
 
 
 
 
50
51
...
47
48
49
50
51
52
53
54
55
56
57
58
0
@@ -47,4 +47,11 @@ module BaseAttachmentTests
0
       end
0
     end
0
   end
0
+
0
+ def test_should_save_without_updating_file
0
+ attachment = upload_file :filename => '/files/foo.txt'
0
+ assert_valid attachment
0
+ assert !attachment.save_attachment?
0
+ assert_nothing_raised { attachment.save! }
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.