This commit is contained in:
Albert Yi
2018-07-25 11:04:50 -07:00
parent 9082ddf455
commit 77854349e5
6 changed files with 37 additions and 22 deletions

View File

@@ -68,6 +68,20 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
end
end
context "for a pixiv post" do
setup do
@source = "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=14901720"
end
should "set the correct url" do
get_auth new_upload_path, @user, params: {url: @source}
assert_response :success
Delayed::Worker.new.work_off
upload = Upload.last
assert_equal(@source, upload.source)
end
end
context "for a twitter post" do
should "render" do
skip "Twitter keys are not set" unless Danbooru.config.twitter_api_key

View File

@@ -168,7 +168,7 @@ class ArtistTest < ActiveSupport::TestCase
should "not allow invalid urls" do
artist = FactoryBot.create(:artist, :url_string => "blah")
assert_equal(false, artist.valid?)
assert_equal(["Url must begin with http:// or https://"], artist.errors[:url])
assert_equal(["blah must begin with http:// or https://"], artist.errors[:url])
end
should "make sure old urls are deleted" do

View File

@@ -12,24 +12,6 @@ module Downloads
super
end
context "An ugoira site for pixiv" do
setup do
@download = Downloads::File.new("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247364")
@tempfile = @download.download!
@tempfile.close!
end
should "capture the data" do
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @download.source)
assert_equal(2, @download.data[:ugoira_frame_data].size)
if @download.data[:ugoira_frame_data][0]["file"]
assert_equal([{"file"=>"000000.jpg", "delay"=>125}, {"file"=>"000001.jpg", "delay"=>125}], @download.data[:ugoira_frame_data])
else
assert_equal([{"delay_msec"=>125}, {"delay_msec"=>125}], @download.data[:ugoira_frame_data])
end
end
end
context "in all cases" do
# Test an old illustration (one uploaded before 2014-09-16). New
# /img-original/ and /img-master/ URLs currently don't work for images
@@ -195,5 +177,23 @@ module Downloads
end
end
end
context "An ugoira site for pixiv" do
setup do
@download = Downloads::File.new("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247364")
@tempfile = @download.download!
@tempfile.close!
end
should "capture the data" do
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @download.source)
assert_equal(2, @download.data[:ugoira_frame_data].size)
if @download.data[:ugoira_frame_data][0]["file"]
assert_equal([{"file"=>"000000.jpg", "delay"=>125}, {"file"=>"000001.jpg", "delay"=>125}], @download.data[:ugoira_frame_data])
else
assert_equal([{"delay_msec"=>125}, {"delay_msec"=>125}], @download.data[:ugoira_frame_data])
end
end
end
end
end