FIX: Optimize images in Onebox (#8471)

This commit ensures that images in Onebox are being optimized, but not
converted to lightbox too.
This commit is contained in:
Dan Ungureanu
2019-12-09 15:39:25 +02:00
committed by GitHub
parent f62b8990ac
commit ebe6fa95be
2 changed files with 20 additions and 4 deletions

View File

@ -946,6 +946,21 @@ describe CookedPostProcessor do
expect(doc.css('.lightbox-wrapper').size).to eq(0)
expect(doc.css('img').first['srcset']).to_not eq(nil)
end
it "optimizes images in Onebox" do
Oneboxer.expects(:onebox)
.with("https://discourse.org", anything)
.returns("<aside class='onebox'><img src='#{upload.url}' width='512' height='384'></aside>")
post = Fabricate(:post, raw: "https://discourse.org")
cpp = CookedPostProcessor.new(post, disable_loading_image: true)
cpp.post_process
doc = Nokogiri::HTML::fragment(cpp.html)
expect(doc.css('.lightbox-wrapper').size).to eq(0)
expect(doc.css('img').first['srcset']).to_not eq(nil)
end
end
context "#post_process_oneboxes" do