Files
danbooru/test/unit/downloads/tumblr_test.rb
r888888888 fc7afd44ea refactor source pixiv test
refactor pixiv download tests
refactor upload test
refactor nico seiga test
refactor twitter tests
2016-09-28 11:25:29 -07:00

50 lines
1.6 KiB
Ruby

require 'test_helper'
module Downloads
class TumblrTest < ActiveSupport::TestCase
def setup
super
@record = true
setup_vcr
end
context "a download for a tumblr 500 sample" do
setup do
@source = "http://24.media.tumblr.com/fc328250915434e66e8e6a92773f79d0/tumblr_mf4nshfibc1s0oswoo1_500.jpg"
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
VCR.use_cassette("downloads-tumblr-test/sample", :record => @vcr_record_option) do
@download.download!
end
end
should "instead change the source to the 1280 version" do
assert_equal("http://24.media.tumblr.com/fc328250915434e66e8e6a92773f79d0/tumblr_mf4nshfibc1s0oswoo1_1280.jpg", @download.source)
end
should "instead download the 1280 version" do
assert_equal(196_617, ::File.size(@tempfile.path))
end
end
context "a download for a tumblr 500 image without a larger size" do
setup do
@source = "http://25.media.tumblr.com/tumblr_lxbzel2H5y1r9yjhso1_500.jpg"
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
VCR.use_cassette("downloads-tumblr-test/sample", :record => @vcr_record_option) do
@download.download!
end
end
should "not change the source" do
assert_equal("http://25.media.tumblr.com/tumblr_lxbzel2H5y1r9yjhso1_500.jpg", @download.source)
end
should "download the 500 version" do
assert_equal(90_122, ::File.size(@tempfile.path))
end
end
end
end