From 3fefb73e900c9d662d9f042b63ac7f477fc86c2a Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 24 Feb 2018 10:31:59 -0600 Subject: [PATCH] Fix #3561: Tumblr: support answer posts. --- app/logical/sources/strategies/tumblr.rb | 4 ++++ test/unit/sources/tumblr_test.rb | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/logical/sources/strategies/tumblr.rb b/app/logical/sources/strategies/tumblr.rb index 8a7d9e7e9..426772474 100644 --- a/app/logical/sources/strategies/tumblr.rb +++ b/app/logical/sources/strategies/tumblr.rb @@ -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 diff --git a/test/unit/sources/tumblr_test.rb b/test/unit/sources/tumblr_test.rb index b1d811d5b..b17b91abc 100644 --- a/test/unit/sources/tumblr_test.rb +++ b/test/unit/sources/tumblr_test.rb @@ -22,7 +22,7 @@ module Sources end should "get the commentary" do - desc = <<-EOS.strip_heredoc.chomp + desc = <<~EOS.chomp

header


plain bold italics strike

@@ -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