updated top the the new version of attachment_fu plugin to work out some
[selectricity-live] / vendor / plugins / attachment_fu / test / processors / rmagick_test.rb
index 13d177af50ef754c075e00b0e2b59225e3b04cbc..8e07f2102bdaa7dd128e85d194d614bd3cca5fc4 100644 (file)
@@ -157,12 +157,14 @@ class RmagickTest < Test::Unit::TestCase
         assert_valid attachment
       end
       assert_kind_of ImageThumbnail,  attachment.thumbnails.first
-      assert_equal attachment.id,     attachment.thumbnails.first.parent.id
-      assert_kind_of FileAttachment,  attachment.thumbnails.first.parent
+      if attachment.thumbnails.first.respond_to?(:parent)
+        assert_equal attachment.id,     attachment.thumbnails.first.parent.id
+        assert_kind_of FileAttachment,  attachment.thumbnails.first.parent
+      end
       assert_equal 'rails_thumb.png', attachment.thumbnails.first.filename
       assert_equal attachment.thumbnails.first.full_filename, attachment.full_filename(attachment.thumbnails.first.thumbnail),
         "#full_filename does not use thumbnail class' path."
-      assert_equal attachment.destroy attachment
+      assert_equal attachment.destroy, attachment
     end
     
     test_against_subclass :test_should_use_thumbnail_subclass, ImageWithThumbsClassFileAttachment
@@ -179,7 +181,7 @@ class RmagickTest < Test::Unit::TestCase
       assert_not_created do
         use_temp_file "files/rails.png" do |file|
           attachment.filename        = 'rails2.png'
-          attachment.temp_path = File.join(fixture_path, file)
+          attachment.temp_paths.unshift File.join(fixture_path, file)
           attachment.save
           new_filenames = [attachment.reload.full_filename] + attachment.thumbnails.collect { |t| t.reload.full_filename }
           new_filenames.each { |f| assert  File.exists?(f), "#{f} does not exist" }
@@ -201,6 +203,14 @@ class RmagickTest < Test::Unit::TestCase
     
     test_against_subclass :test_should_delete_file_when_in_file_system_when_attachment_record_destroyed, ImageWithThumbsFileAttachment
     
+    def test_should_have_full_filename_method(klass = FileAttachment)
+      attachment_model klass
+      attachment = upload_file :filename => '/files/rails.png'
+      assert_respond_to attachment, :full_filename
+    end
+    
+    test_against_subclass :test_should_have_full_filename_method, FileAttachment
+    
     def test_should_overwrite_old_thumbnail_records_when_updating(klass = ImageWithThumbsAttachment)
       attachment_model klass
       attachment = nil
@@ -210,7 +220,11 @@ class RmagickTest < Test::Unit::TestCase
       assert_not_created do # no new db_file records
         use_temp_file "files/rails.png" do |file|
           attachment.filename             = 'rails2.png'
-          attachment.temp_path = File.join(fixture_path, file)
+          # The above test (#test_should_have_full_filename_method) to pass before be can set the temp_path below -- 
+          # #temp_path calls #full_filename, which is not getting mixed into the attachment.  Maybe we don't need to
+          # set temp_path at all?
+          #
+          # attachment.temp_paths.unshift File.join(fixture_path, file)
           attachment.save!
         end
       end
@@ -238,4 +252,4 @@ class RmagickTest < Test::Unit::TestCase
       puts "RMagick not installed, no tests running"
     end
   end
-end
\ No newline at end of file
+end

Benjamin Mako Hill || Want to submit a patch?