0
@@ -4,12 +4,20 @@ ASSET_PATH = File.join(RAILS_ROOT, 'test/fixtures/assets')
0
class AssetTest < Test::Unit::TestCase
0
fixtures :sites, :assets
0
+ def test_should_upload_and_create_asset_records
0
+ assert_difference sites(:first).assets, :count do
0
+ assert_difference Asset, :count, 3 do # asset + 2 thumbnails
0
def test_should_upload_file
0
- assert File.file?(File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo.png'))
0
- assert File.file?(File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_thumb.png'))
0
- assert File.file?(File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_tiny.png'))
0
+ assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo.png')
0
+ assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_thumb.png')
0
+ assert_file_exists File.join(ASSET_PATH, sites(:first).host, now.year.to_s, now.month.to_s, now.day.to_s, 'logo_tiny.png')
0
def test_should_set_site_id
0
@@ -28,7 +36,31 @@ class AssetTest < Test::Unit::TestCase
0
Technoweenie::ActsAsAttachment.content_types.each do |content_type|
0
a.content_type = content_type
0
+ assert a.image?, "#{content_type} was not an image"
0
+ def test_should_report_movie_type
0
+ ['video/mpeg', 'video/quicktime'].each do |content_type|
0
+ a.content_type = content_type
0
+ assert a.movie?, "#{content_type} was not a movie"
0
+ def test_should_report_audio_type
0
+ ['audio/mpeg', 'application/ogg', 'audio/wav'].each do |content_type|
0
+ a.content_type = content_type
0
+ assert a.audio?, "#{content_type} was not audio"
0
+ def test_should_report_document_type
0
+ ['application/pdf', 'application/msword', 'text/html', 'application/x-gzip'].each do |content_type|
0
+ a.content_type = content_type
0
+ assert a.document?, "#{content_type} was not a document"
0
@@ -42,11 +74,7 @@ class AssetTest < Test::Unit::TestCase
0
- assert_difference sites(:first).assets, :count do
0
- assert_difference Asset, :count, 3 do # asset + 2 thumbnails
0
- sites(:first).assets.create(:filename => 'logo.png', :content_type => 'image/png',
0
- :attachment_data => IO.read(File.join(RAILS_ROOT, 'public/images/logo.png')))
0
+ sites(:first).assets.create(:filename => 'logo.png', :content_type => 'image/png',
0
+ :attachment_data => IO.read(File.join(RAILS_ROOT, 'public/images/logo.png')))
Comments
No one has commented yet.