Permalink
Browse files

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
  • Loading branch information...
1 parent d35205c commit e279f106b4a05cc89e8d246fc72875f6a651b1c5 technoweenie committed Jan 11, 2007
Showing with 8 additions and 1 deletion.
  1. +1 −1 lib/technoweenie/attachment_fu.rb
  2. +7 −0 test/base_attachment_tests.rb
View
2 lib/technoweenie/attachment_fu.rb
@@ -78,7 +78,7 @@ def has_attachment(options = {})
else
include Technoweenie::AttachmentFu::Processors.const_get("#{options[:processor].to_s.classify}")
end
- before_save :process_attachment
+ after_validation :process_attachment
end
options[:content_type] = [options[:content_type]].flatten.collect { |t| t == :image ? Technoweenie::AttachmentFu.content_types : t }.flatten unless options[:content_type].nil?
View
7 test/base_attachment_tests.rb
@@ -47,4 +47,11 @@ def test_should_overwrite_old_contents_when_updating
end
end
end
+
+ def test_should_save_without_updating_file
+ attachment = upload_file :filename => '/files/foo.txt'
+ assert_valid attachment
+ assert !attachment.save_attachment?
+ assert_nothing_raised { attachment.save! }
+ end
end

0 comments on commit e279f10

Please sign in to comment.