Merge pull request #2782 from evazion/fix-2779

Fix #2779: Erroneous pixiv_id parsed for novel/background/profile images
This commit is contained in:
Albert Yi
2016-12-05 11:44:38 -08:00
committed by GitHub
12 changed files with 19612 additions and 11 deletions

View File

@@ -178,6 +178,53 @@ module Downloads
assert_downloaded(@file_size, @zip_file, "downloads-pixiv-test/download-ugoira-zip-file")
end
end
context "downloading a profile image" do
should "download old profile images" do
@file_url = "http://img12.pixiv.net/profile/rapattu/119950.jpg"
@file_size = 16238
assert_not_rewritten(@file_url)
assert_downloaded(@file_size, @file_url)
end
should "download new profile images" do
@file_url = "http://i2.pixiv.net/img130/profile/minono_aki/8733472.jpg"
@file_size = 23266
assert_not_rewritten(@file_url)
assert_downloaded(@file_size, @file_url)
end
end
context "downloading a background image" do
should "download the image" do
@file_url = "http://i1.pixiv.net/background/img/2016/05/17/12/05/48/2074388_d4ac52034f7ca0af3e083d59fde7e97f.jpg"
@file_size = 386_500
assert_not_rewritten(@file_url)
assert_downloaded(@file_size, @file_url)
end
end
context "downloading a novel image" do
should "download old novel images" do
@file_url = "http://i2.pixiv.net/img20/img/a-park/novel/3607898.jpg"
@file_size = 125_635
assert_not_rewritten(@file_url)
assert_downloaded(@file_size, @file_url)
end
should "download new novel images" do
@file_url = "http://i1.pixiv.net/novel-cover-original/img/2016/11/03/20/10/58/7436075_f75af69f3eacd1656d3733c72aa959cf.jpg"
@file_size = 316_133
assert_not_rewritten(@file_url)
assert_downloaded(@file_size, @file_url)
end
end
end
end
end

View File

@@ -1227,6 +1227,26 @@ class PostTest < ActiveSupport::TestCase
assert_equal(18557054, @post.pixiv_id)
@post.pixiv_id = nil
end
context "but doesn't have a pixiv id" do
should "not save the pixiv id" do
@post.pixiv_id = 1234
@post.update(source: "http://i1.pixiv.net/novel-cover-original/img/2016/11/03/20/10/58/7436075_f75af69f3eacd1656d3733c72aa959cf.jpg")
assert_equal(nil, @post.pixiv_id)
@post.pixiv_id = 1234
@post.update(source: "http://i2.pixiv.net/background/img/2016/10/30/12/27/30/7059005_da9946b806c10d391a81ed1117cd33d6.jpg")
assert_equal(nil, @post.pixiv_id)
@post.pixiv_id = 1234
@post.update(source: "http://i1.pixiv.net/img15/img/omega777/novel/2612734.jpg")
assert_equal(nil, @post.pixiv_id)
@post.pixiv_id = 1234
@post.update(source: "http://img08.pixiv.net/profile/nice/1408837.jpg")
assert_equal(nil, @post.pixiv_id)
end
end
end
should "normalize pixiv links" do