refactored resizer to use imagemagick, fixed some tests
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user