From 8da3474a8bf25bde41d47b171146eccca489751f Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 29 Nov 2018 23:01:08 -0600 Subject: [PATCH] Fix #3994: Some deviantart images mistakenly choosing preview image. --- app/logical/sources/strategies/deviant_art.rb | 2 +- test/unit/sources/deviantart_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index e9094236c..67fe3d4c4 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -70,7 +70,7 @@ module Sources if api_deviation.blank? [url] # work is downloadable - elsif api_deviation[:is_downloadable] && api_deviation[:download_filesize] != api_deviation.dig(:content, :filesize) + elsif api_deviation[:is_downloadable] src = api_download[:src] src.gsub!(%r!\Ahttps?://s3\.amazonaws\.com/!i, "https://") src.gsub!(/\?.*\z/, "") # strip s3 query params diff --git a/test/unit/sources/deviantart_test.rb b/test/unit/sources/deviantart_test.rb index 2065ea3f5..f7780a5b5 100644 --- a/test/unit/sources/deviantart_test.rb +++ b/test/unit/sources/deviantart_test.rb @@ -43,6 +43,15 @@ module Sources end end + context "The source for a download-enabled DeviantArt artwork page" do + should "get the download image url" do + @site = Sources::Strategies.find("https://www.deviantart.com/len1/art/All-that-Glitters-II-774592781") + + assert_equal(["http://origin-orig.deviantart.net/a713/f/2018/333/3/6/all_that_glitters_ii_by_len1-dct67m5.jpg"], @site.image_urls) + assert_equal(@site.image_url, @site.canonical_url) + end + end + context "The source for a DeviantArt image url" do should "fetch the source data" do @site = Sources::Strategies.find("https://pre00.deviantart.net/b5e6/th/pre/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg")