FIX: Remove onebox src from `Jobs::PullHotlinkedImages`.
The test that was added is incorrect because the post was not cooked.
This commit is contained in:
parent
457be89445
commit
c9db897777
|
@ -71,6 +71,7 @@ module Jobs
|
||||||
filename = File.basename(URI.parse(src).path)
|
filename = File.basename(URI.parse(src).path)
|
||||||
filename << File.extname(hotlinked.path) unless filename["."]
|
filename << File.extname(hotlinked.path) unless filename["."]
|
||||||
upload = UploadCreator.new(hotlinked, filename, origin: src).create_for(post.user_id)
|
upload = UploadCreator.new(hotlinked, filename, origin: src).create_for(post.user_id)
|
||||||
|
|
||||||
if upload.persisted?
|
if upload.persisted?
|
||||||
downloaded_urls[src] = upload.url
|
downloaded_urls[src] = upload.url
|
||||||
downloaded_images[remove_scheme(src)] = upload.id
|
downloaded_images[remove_scheme(src)] = upload.id
|
||||||
|
@ -148,7 +149,7 @@ module Jobs
|
||||||
def extract_images_from(html)
|
def extract_images_from(html)
|
||||||
doc = Nokogiri::HTML::fragment(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("img.avatar") -
|
||||||
doc.css(".lightbox img[src]")
|
doc.css(".lightbox img[src]")
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,23 +98,6 @@ describe Jobs::PullHotlinkedImages do
|
||||||
expect(post.uploads).to contain_exactly(upload)
|
expect(post.uploads).to contain_exactly(upload)
|
||||||
end
|
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
|
it 'replaces markdown image' do
|
||||||
post = Fabricate(:post, raw: <<~MD)
|
post = Fabricate(:post, raw: <<~MD)
|
||||||
[![some test](#{image_url})](https://somelink.com)
|
[![some test](#{image_url})](https://somelink.com)
|
||||||
|
|
Loading…
Reference in New Issue