FIX: don't use srcset on cropped thumbnails

This commit is contained in:
Régis Hanol
2018-10-25 16:08:10 +02:00
parent a6eca28ec6
commit 306d77b54f
2 changed files with 35 additions and 17 deletions

View File

@ -58,10 +58,10 @@ describe CookedPostProcessor do
end
context "responsive images" do
before { SiteSetting.responsive_post_image_sizes = "1|1.5|3" }
it "includes responsive images on demand" do
SiteSetting.responsive_post_image_sizes = "1|1.5|3"
upload = Fabricate(:upload, width: 2000, height: 1500, filesize: 10000)
post = Fabricate(:post, raw: "hello <img src='#{upload.url}'>")
@ -93,8 +93,29 @@ describe CookedPostProcessor do
cpp.post_process_images
# 1.5x is skipped cause we have a missing thumb
expect(cpp.html).to include('srcset="http://a.b.c/666x500.jpg, http://a.b.c/1998x1500.jpg 3.0x"')
expect(cpp.html).to include('srcset="http://a.b.c/666x500.jpg, http://a.b.c/1998x1500.jpg 3x"')
end
it "doesn't include response images for cropped images" do
upload = Fabricate(:upload, width: 200, height: 4000, filesize: 12345)
post = Fabricate(:post, raw: "hello <img src='#{upload.url}'>")
# fake some optimized images
OptimizedImage.create!(
url: 'http://a.b.c/200x500.jpg',
width: 200,
height: 500,
upload_id: upload.id,
sha1: SecureRandom.hex,
extension: '.jpg',
filesize: 500
)
cpp = CookedPostProcessor.new(post)
cpp.add_to_size_cache(upload.url, 200, 4000)
cpp.post_process_images
expect(cpp.html).to_not include('srcset="')
end
end