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 !
Check for current type of :thumbnails option.

git-svn-id: 
http://svn.techno-weenie.net/projects/plugins/attachment_fu@2831 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Mon Apr 02 14:49:10 -0700 2007
commit  8fbfceecf60444eb75182687a3926d1f13fb5ab1
tree    d3cbbf9f36088ad9f98aad0c41ecd859d2f16458
parent  1c14574906dcdcbfa445b94558a7e0789ed68850
...
 
 
 
1
2
3
...
1
2
3
4
5
6
0
@@ -1,3 +1,6 @@
0
+* April 2, 2007 *
0
+
0
+* Check for current type of :thumbnails option.
0
 * allow customization of the S3 configuration file path with the :s3_config_path option.
0
 * Don't try to remove thumbnails if there aren't any. Closes #3 [ben stiglitz]
0
 
...
46
47
48
 
 
 
 
49
50
51
...
46
47
48
49
50
51
52
53
54
55
0
@@ -46,6 +46,10 @@ module Technoweenie # :nodoc:
0
         options[:s3_access] ||= :public_read
0
         options[:content_type] = [options[:content_type]].flatten.collect! { |t| t == :image ? Technoweenie::AttachmentFu.content_types : t }.flatten unless options[:content_type].nil?
0
         
0
+ unless options[:thumbnails].is_a?(Hash)
0
+ raise ArgumentError, ":thumbnails option should be a hash: e.g. :thumbnails => { :foo => '50x50' }"
0
+ end
0
+
0
         # doing these shenanigans so that #attachment_options is available to processors and backends
0
         class_inheritable_accessor :attachment_options
0
         self.attachment_options = options
...
54
55
56
 
 
 
 
 
 
 
57
58
...
54
55
56
57
58
59
60
61
62
63
64
65
0
@@ -54,4 +54,11 @@ class BasicTest < Test::Unit::TestCase
0
     @attachment.filename = 'foo.bar.baz'
0
     assert_equal 'foo.bar_blah.baz', @attachment.thumbnail_name_for(:blah)
0
   end
0
+
0
+ def test_should_require_valid_thumbnails_option
0
+ klass = Class.new(ActiveRecord::Base)
0
+ assert_raise ArgumentError do
0
+ klass.has_attachment :thumbnails => []
0
+ end
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.