Permalink
Browse files

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
  • Loading branch information...
1 parent 1c14574 commit 8fbfceecf60444eb75182687a3926d1f13fb5ab1 technoweenie committed Apr 2, 2007
Showing with 14 additions and 0 deletions.
  1. +3 −0 CHANGELOG
  2. +4 −0 lib/technoweenie/attachment_fu.rb
  3. +7 −0 test/basic_test.rb
View
@@ -1,3 +1,6 @@
+* April 2, 2007 *
+
+* Check for current type of :thumbnails option.
* allow customization of the S3 configuration file path with the :s3_config_path option.
* Don't try to remove thumbnails if there aren't any. Closes #3 [ben stiglitz]
@@ -46,6 +46,10 @@ def has_attachment(options = {})
options[:s3_access] ||= :public_read
options[:content_type] = [options[:content_type]].flatten.collect! { |t| t == :image ? Technoweenie::AttachmentFu.content_types : t }.flatten unless options[:content_type].nil?
+ unless options[:thumbnails].is_a?(Hash)
+ raise ArgumentError, ":thumbnails option should be a hash: e.g. :thumbnails => { :foo => '50x50' }"
+ end
+
# doing these shenanigans so that #attachment_options is available to processors and backends
class_inheritable_accessor :attachment_options
self.attachment_options = options
View
@@ -54,4 +54,11 @@ def test_should_convert_thumbnail_name
@attachment.filename = 'foo.bar.baz'
assert_equal 'foo.bar_blah.baz', @attachment.thumbnail_name_for(:blah)
end
+
+ def test_should_require_valid_thumbnails_option
+ klass = Class.new(ActiveRecord::Base)
+ assert_raise ArgumentError do
+ klass.has_attachment :thumbnails => []
+ end
+ end
end

0 comments on commit 8fbfcee

Please sign in to comment.