Fix #3561: Tumblr: support answer posts.

This commit is contained in:
evazion
2018-02-24 10:31:59 -06:00
parent 916a57b2fd
commit 3fefb73e90
2 changed files with 23 additions and 2 deletions

View File

@@ -35,6 +35,8 @@ module Sources::Strategies
case post[:type]
when "text", "link"
post[:title]
when "answer"
post[:question]
else
nil
end
@@ -48,6 +50,8 @@ module Sources::Strategies
post[:description]
when "photo", "video"
post[:caption]
when "answer"
post[:answer]
else
nil
end

View File

@@ -22,7 +22,7 @@ module Sources
end
should "get the commentary" do
desc = <<-EOS.strip_heredoc.chomp
desc = <<~EOS.chomp
<h2>header</h2>
<hr><p>plain <b>bold</b> <i>italics</i> <strike>strike</strike></p>
@@ -43,7 +43,7 @@ module Sources
end
should "get the dtext-ified commentary" do
desc = <<-EOS.strip_heredoc.chomp
desc = <<~EOS.chomp
h2. header
plain [b]bold[/b] [i]italics[/i] [s]strike[/s]
@@ -159,5 +159,22 @@ module Sources
assert_equal(urls, @site.image_urls)
end
end
context "The source for a 'http://*.tumblr.com/post/*' answer post with inline images" do
setup do
@site = Sources::Site.new("https://noizave.tumblr.com/post/171237880542/test-ask")
@site.get
end
should "get the image urls" do
urls = ["http://data.tumblr.com/cb481f031010e8ddad564b2150149c9a/tumblr_inline_p4nxoyLrSh1v11u29_raw.png"]
assert_equal(urls, @site.image_urls)
end
should "get the commentary" do
assert_equal("test ask", @site.artist_commentary_title)
assert_match("test answer", @site.artist_commentary_desc)
end
end
end
end