Sha256: a2dadf4db19c3282eed5bec7a45bcaad49144fa3980976e4acf8356c7d0f2c70

Contents?: true

Size: 1.89 KB

Versions: 10

Compression:

Stored size: 1.89 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))

class OrphanAttachmentTest < Test::Unit::TestCase
  include BaseAttachmentTests
  attachment_model OrphanAttachment
  
  def test_should_create_image_from_uploaded_file
    assert_created do
      attachment = upload_file :filename => '/files/rails.png'
      assert_valid attachment
      assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
      assert  attachment.image?
      assert !attachment.size.zero?
    end
  end
  
  def test_should_create_file_from_uploaded_file
    assert_created do
      attachment = upload_file :filename => '/files/foo.txt'
      assert_valid attachment
      assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
      assert  attachment.image?
      assert !attachment.size.zero?
    end
  end
  
  def test_should_create_image_from_uploaded_file_with_custom_content_type
    assert_created do
      attachment = upload_file :content_type => 'foo/bar', :filename => '/files/rails.png'
      assert_valid attachment
      assert !attachment.image?
      assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
      assert !attachment.size.zero?
      #assert_equal 1784, attachment.size
    end
  end
  
  def test_should_create_thumbnail
    attachment = upload_file :filename => '/files/rails.png'
    
    assert_raise Technoweenie::AttachmentFu::ThumbnailError do
      attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 50, 50)
    end
  end
  
  def test_should_create_thumbnail_with_geometry_string
   attachment = upload_file :filename => '/files/rails.png'
    
    assert_raise Technoweenie::AttachmentFu::ThumbnailError do
      attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 'x50')
    end
  end
end

class MinimalAttachmentTest < OrphanAttachmentTest
  attachment_model MinimalAttachment
end

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
pager-attachment_fu-1.0.20080506 test/extra_attachment_test.rb
pager-attachment_fu-1.0.20080507 test/extra_attachment_test.rb
attachmerb_fu-0.0.1 lib/test/extra_attachment_test.rb
railscart-0.0.4 starter_app/vendor/plugins/attachment_fu/test/extra_attachment_test.rb
spree-0.0.6 starter-app/vendor/plugins/attachment_fu/test/extra_attachment_test.rb
spree-0.0.5 starter-app/vendor/plugins/attachment_fu/test/extra_attachment_test.rb
spree-0.0.8 starter-app/vendor/plugins/attachment_fu/test/extra_attachment_test.rb
spree-0.0.9 vendor/plugins/attachment_fu/test/extra_attachment_test.rb
spree-0.0.7 starter-app/vendor/plugins/attachment_fu/test/extra_attachment_test.rb
spree-0.2.0 vendor/plugins/attachment_fu/test/extra_attachment_test.rb