FIX: Remove onebox src from `Jobs::PullHotlinkedImages`.

approved
#1

FIX: Remove onebox src from Jobs::PullHotlinkedImages.

The test that was added is incorrect because the post was not cooked.

diff --git a/app/jobs/regular/pull_hotlinked_images.rb b/app/jobs/regular/pull_hotlinked_images.rb
index de8bc07..a42d45c 100644
--- a/app/jobs/regular/pull_hotlinked_images.rb
+++ b/app/jobs/regular/pull_hotlinked_images.rb
@@ -71,6 +71,7 @@ module Jobs
                   filename = File.basename(URI.parse(src).path)
                   filename << File.extname(hotlinked.path) unless filename["."]
                   upload = UploadCreator.new(hotlinked, filename, origin: src).create_for(post.user_id)
+
                   if upload.persisted?
                     downloaded_urls[src] = upload.url
                     downloaded_images[remove_scheme(src)] = upload.id
@@ -148,7 +149,7 @@ module Jobs
     def extract_images_from(html)
       doc = Nokogiri::HTML::fragment(html)
 
-      doc.css("img[src], a.lightbox[href], a.onebox[href]") -
+      doc.css("img[src], a.lightbox[href]") -
         doc.css("img.avatar") -
         doc.css(".lightbox img[src]")
     end
diff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rb
index 25b086f..17a1188 100644
--- a/spec/jobs/pull_hotlinked_images_spec.rb
+++ b/spec/jobs/pull_hotlinked_images_spec.rb
@@ -98,23 +98,6 @@ describe Jobs::PullHotlinkedImages do
       expect(post.uploads).to contain_exactly(upload)
     end
 
-    it 'replaces direct links' do
-      post = Fabricate(:post, raw: <<~MD)
-      #{image_url}
-      #{image_url}
-      MD
-
-      expect { Jobs::PullHotlinkedImages.new.execute(post_id: post.id) }
-        .to change { Upload.count }.by(1)
-
-      post.reload
-
-      expect(post.raw).to eq(<<~MD.chomp)
-      ![](#{Upload.last.short_url})
-      ![](#{Upload.last.short_url})
-      MD
-    end
-
     it 'replaces markdown image' do
       post = Fabricate(:post, raw: <<~MD)
       [![some test](#{image_url})](https://somelink.com)

GitHub sha: c9db8977

1 Like
Approved #2