refactored resizer to use imagemagick, fixed some tests

This commit is contained in:
albert
2011-09-16 12:38:56 -04:00
parent fbc1fb1f51
commit a717134163
31 changed files with 69 additions and 1648 deletions

View File

@@ -38,4 +38,17 @@ class DownloadTest < ActiveSupport::TestCase
assert_match(/image\/gif/, @download.content_type)
end
end
context "a post download for a pixiv manga page" do
setup do
@source = "http://img65.pixiv.net/img/kiyoringo/21755794_p2.png"
@tempfile = Tempfile.new("danbooru-test")
@download = Download.new(@source, @tempfile.path)
end
should "download the big version" do
@download.download!
assert_equal("http://img65.pixiv.net/img/kiyoringo/21755794_big_p2.png", @download.source)
end
end
end

View File

@@ -60,7 +60,7 @@ class NoteTest < ActiveSupport::TestCase
assert_nil(@post.last_noted_at)
@note.update_attributes(:x => 1000)
@post.reload
assert_equal(@post.last_noted_at, @note.updated_at)
assert_equal(@post.last_noted_at.to_i, @note.updated_at.to_i)
end
should "create a version" do

View File

@@ -13,16 +13,5 @@ class PixivProxyTest < ActiveSupport::TestCase
assert(first_tag[0] =~ /./)
assert(first_tag[1] =~ /tags\.php\?tag=/)
end
should "get a manga page" do
url ="http://img65.pixiv.net/img/kiyoringo/21755794_p2.png"
results = PixivProxy.get_single(url)
assert_equal("member.php?id=4015", results[:profile_url])
assert(results[:jp_tags].size > 0)
first_tag = results[:jp_tags][0]
assert_equal(2, first_tag.size)
assert(first_tag[0] =~ /./)
assert(first_tag[1] =~ /tags\.php\?tag=/)
end
end
end

View File

@@ -110,22 +110,12 @@ class UploadTest < ActiveSupport::TestCase
@upload.calculate_hash(@upload.file_path)
@upload.calculate_dimensions(@upload.file_path)
assert_nothing_raised {@upload.generate_resizes(@upload.file_path)}
unless Danbooru.respond_to? :is_fallback
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
assert_equal(7265, File.size(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.medium_image_width)))
assert_equal(43474, File.size(@upload.resized_file_path_for(Danbooru.config.medium_image_width)))
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
assert_equal(198583, File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
else
# Different set of expected file sizes due to using a different compression algorithm
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
assert_equal(7405, File.size(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.medium_image_width)))
assert_equal(43577, File.size(@upload.resized_file_path_for(Danbooru.config.medium_image_width)))
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
assert_equal(198666, File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
end
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
assert_equal(4817, File.size(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.medium_image_width)))
assert_equal(42990, File.size(@upload.resized_file_path_for(Danbooru.config.medium_image_width)))
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
assert_equal(197046, File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
end
end