Skip to content

A platform for community discussion. Free, open, simple.

DEV: Improve tests to assert that the right HTML is generated.

Guo Xiang Tanb64d760bb34b
diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb
index 21d360d0b60..7c9b35ef2a4 100644
--- a/spec/components/cooked_post_processor_spec.rb
+++ b/spec/components/cooked_post_processor_spec.rb
@@ -259,7 +259,6 @@ 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
@@ -289,7 +288,7 @@ describe CookedPostProcessor do
)
# Fake a loading image
- OptimizedImage.create!(
+ optimized_image = OptimizedImage.create!(
url: 'http://a.b.c/10x10.png',
width: CookedPostProcessor::LOADING_SIZE,
height: CookedPostProcessor::LOADING_SIZE,
@@ -303,10 +302,12 @@ describe CookedPostProcessor do
cpp.add_to_size_cache(upload.url, 2000, 1500)
cpp.post_process_images
- expect(cpp.loading_image(upload)).to be_present
+ html = cpp.html
+
+ expect(html).to include(%Q|data-small-upload="#{optimized_image.url}"|)
# 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 3x"')
+ expect(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