major bug fix with cache.rb, work on implication tests

This commit is contained in:
albert
2010-02-12 15:17:15 -05:00
parent ba05f727b0
commit bc7bd0b386
15 changed files with 206 additions and 520 deletions

View File

@@ -8,21 +8,21 @@ class UploadTest < ActiveSupport::TestCase
context "image size calculator" do
should "discover the dimensions for a JPG" do
@upload = Factory.create(:uploaded_jpg_upload)
@upload = Factory.create(:jpg_upload)
assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)}
assert_equal(500, @upload.image_width)
assert_equal(335, @upload.image_height)
end
should "discover the dimensions for a PNG" do
@upload = Factory.create(:uploaded_png_upload)
@upload = Factory.create(:png_upload)
assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)}
assert_equal(768, @upload.image_width)
assert_equal(1024, @upload.image_height)
end
should "discover the dimensions for a GIF" do
@upload = Factory.create(:uploaded_gif_upload)
@upload = Factory.create(:gif_upload)
assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)}
assert_equal(400, @upload.image_width)
assert_equal(400, @upload.image_height)
@@ -31,7 +31,7 @@ class UploadTest < ActiveSupport::TestCase
context "content type calculator" do
should "know how to parse jpeg, png, gif, and swf file extensions" do
@upload = Factory.create(:uploaded_jpg_upload)
@upload = Factory.create(:jpg_upload)
assert_equal("image/jpeg", @upload.file_ext_to_content_type("test.jpeg"))
assert_equal("image/gif", @upload.file_ext_to_content_type("test.gif"))
assert_equal("image/png", @upload.file_ext_to_content_type("test.png"))
@@ -40,7 +40,7 @@ class UploadTest < ActiveSupport::TestCase
end
should "know how to parse jpeg, png, gif, and swf content types" do
@upload = Factory.create(:uploaded_jpg_upload)
@upload = Factory.create(:jpg_upload)
assert_equal("jpg", @upload.content_type_to_file_ext("image/jpeg"))
assert_equal("gif", @upload.content_type_to_file_ext("image/gif"))
assert_equal("png", @upload.content_type_to_file_ext("image/png"))
@@ -51,7 +51,7 @@ class UploadTest < ActiveSupport::TestCase
context "downloader" do
should "initialize the final path and content type after downloading a file" do
@upload = Factory.create(:downloadable_upload)
@upload = Factory.create(:source_upload)
path = "#{Rails.root}/tmp/test.download.jpg"
assert_nothing_raised {@upload.download_from_source(path)}
assert(File.exists?(path))
@@ -76,7 +76,7 @@ class UploadTest < ActiveSupport::TestCase
context "hash calculator" do
should "caculate the hash" do
@upload = Factory.create(:uploaded_jpg_upload)
@upload = Factory.create(:jpg_upload)
@upload.calculate_hash(@upload.file_path)
assert_equal("ecef68c44edb8a0d6a3070b5f8e8ee76", @upload.md5)
end
@@ -91,7 +91,7 @@ class UploadTest < ActiveSupport::TestCase
end
should "generate several resized versions of the image" do
@upload = Factory.create(:uploaded_large_jpg_upload)
@upload = Factory.create(:large_jpg_upload)
@upload.calculate_hash(@upload.file_path)
@upload.calculate_dimensions(@upload.file_path)
assert_nothing_raised {@upload.generate_resizes(@upload.file_path)}
@@ -105,7 +105,7 @@ class UploadTest < ActiveSupport::TestCase
end
should "process completely for a downloaded image" do
@upload = Factory.create(:downloadable_upload,
@upload = Factory.create(:source_upload,
:rating => "s",
:uploader_ip_addr => "127.0.0.1",
:tag_string => "hoge foo"
@@ -130,7 +130,7 @@ class UploadTest < ActiveSupport::TestCase
end
should "process completely for an uploaded image" do
@upload = Factory.create(:uploaded_jpg_upload,
@upload = Factory.create(:jpg_upload,
:rating => "s",
:uploader_ip_addr => "127.0.0.1",
:tag_string => "hoge foo"