<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -52,6 +52,7 @@ module HasImage
       {
         :resize_to =&gt; &quot;200x200&quot;,
         :thumbnails =&gt; {},
+        :auto_generate_thumbnails =&gt; true,
         :max_size =&gt; 12.megabytes,
         :min_size =&gt; 4.kilobytes,
         :path_prefix =&gt; klass.table_name,</diff>
      <filename>lib/has_image.rb</filename>
    </modified>
    <modified>
      <diff>@@ -84,7 +84,7 @@ module HasImage
     def install_images(object)
       generated_name = Storage.generated_file_name(object)
       install_main_image(object.has_image_id, generated_name)
-      generate_thumbnails(object.has_image_id, generated_name) unless options[:thumbnails].empty?
+      generate_thumbnails(object.has_image_id, generated_name) if thumbnails_needed?
       return generated_name
     ensure  
       @temp_file.close! if !@temp_file.closed?
@@ -169,6 +169,7 @@ module HasImage
     #
     #  /var/sites/example.org/production/public/photos/0000/0001
     def path_for(id)
+      debugger if $debug
       File.join(options[:base_path], options[:path_prefix], Storage.partitioned_path(id))
     end
     
@@ -191,6 +192,11 @@ module HasImage
       end
     end
     
+    # used in #install_images
+    def thumbnails_needed?
+      !options[:thumbnails].empty? &amp;&amp; options[:auto_generate_thumbnails]
+    end
+    
     # Instantiates the processor using the options set in my contructor (if
     # not already instantiated), stores it in an instance variable, and
     # returns it.</diff>
      <filename>lib/has_image/storage.rb</filename>
    </modified>
    <modified>
      <diff>@@ -118,6 +118,16 @@ class StorageTest &lt; Test::Unit::TestCase
     assert @storage.remove_images(stub(:has_image_id =&gt; 1), @name)
   end
   
+  def test_install_images_doesnt_automatically_generate_thumbnails_if_that_option_is_set
+    @storage = HasImage::Storage.new(default_options.merge(
+      :thumbnails =&gt; {:two =&gt; &quot;200x200&quot;},
+      :auto_generate_thumbnails =&gt; false
+    ))
+    @storage.image_data = temp_file(&quot;image.jpg&quot;)
+    @storage.expects(:generate_thumbnails).never
+    @storage.install_images(stub(:has_image_id =&gt; 1))
+  end
+
   def test_image_not_too_small
     @storage = HasImage::Storage.new(default_options.merge(:min_size =&gt; 1.kilobyte))
     @storage.image_data = temp_file(&quot;image.jpg&quot;)</diff>
      <filename>test/storage_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,8 +10,9 @@ end
 
 class PicTest &lt; Test::Unit::TestCase
   def setup
+    # Note: Be sure to not set the whole options hash in your tests below
     Pic.has_image_options = HasImage.default_options_for(Pic)
-    Pic.has_image_options[:base_path] = File.join(RAILS_ROOT, '/tmp')
+    Pic.has_image_options[:base_path] = File.join(RAILS_ROOT, 'tmp')
   end
   
   def teardown
@@ -64,10 +65,23 @@ class PicTest &lt; Test::Unit::TestCase
   def test_default_options_respect_table_name
     assert_equal 'pics', HasImage.default_options_for(PicWithDifferentTableName)[:path_prefix]
   end
+  
+  def test_generate_thumbnails_on_create
+    Pic.has_image_options[:thumbnails] = {:tiny =&gt; &quot;16x16&quot;}
+    @pic = Pic.create!(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
+    assert File.exist?(@pic.absolute_path(:tiny))
+  end
+  
+  def test_doesnt_generate_thumbnails_if_option_disabled
+    Pic.has_image_options[:thumbnails] = {:tiny =&gt; &quot;16x16&quot;}
+    Pic.has_image_options[:auto_generate_thumbnails] = false
+    @pic = Pic.create!(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
+    assert !File.exist?(@pic.absolute_path(:tiny))
+  end
 
   def test_regenerate_thumbnails_succeeds
-    Pic.has_image_options = HasImage.default_options_for(Pic).merge(
-      :thumbnails =&gt; {:small =&gt; &quot;100x100&quot;, :tiny =&gt; &quot;16x16&quot;})
+    Pic.has_image_options[:thumbnails] = {:small =&gt; &quot;100x100&quot;, :tiny =&gt; &quot;16x16&quot;}
+    
     @pic = Pic.new(:image_data =&gt; fixture_file_upload(&quot;/image.jpg&quot;, &quot;image/jpeg&quot;))
     @pic.save!
     assert @pic.regenerate_thumbnails</diff>
      <filename>test_rails/pic_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>05a2527dd190e39d1ae60f7e48f40ad5c79002ab</id>
    </parent>
  </parents>
  <author>
    <name>Gerrit Kaiser</name>
    <email>gerrit@gerritkaiser.de</email>
  </author>
  <url>http://github.com/norman/has_image/commit/f7f2e4070d7ebd5313fac29d423c4388d62195e9</url>
  <id>f7f2e4070d7ebd5313fac29d423c4388d62195e9</id>
  <committed-date>2008-10-21T21:26:14-07:00</committed-date>
  <authored-date>2008-10-20T22:15:35-07:00</authored-date>
  <message>fixed filesystem-cleanup in pic_test
introduced option to has_image to control thumbnail generation in a callback</message>
  <tree>2eddec718769cd99da4958b76d7b9af3b19778bd</tree>
  <committer>
    <name>Gerrit Kaiser</name>
    <email>gerrit@gerritkaiser.de</email>
  </committer>
</commit>
