DEV: Make `CookedPostProcessor#post_process_images` method private.

DEV: Make CookedPostProcessor#post_process_images method private.

diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb
index 5ca50d5..1182818 100644
--- a/lib/cooked_post_processor.rb
+++ b/lib/cooked_post_processor.rb
@@ -65,15 +65,6 @@ class CookedPostProcessor
     BadgeGranter.grant(Badge.find(Badge::FirstReplyByEmail), @post.user, post_id: @post.id) if @post.is_reply_by_email?
   end
 
-  def post_process_images
-    extract_images.each do |img|
-      unless add_image_placeholder!(img)
-        limit_size!(img)
-        convert_to_link!(img)
-      end
-    end
-  end
-
   def post_process_quotes
     @doc.css("aside.quote").each do |q|
       post_number = q['data-post']
@@ -688,6 +679,15 @@ class CookedPostProcessor
 
   private
 
+  def post_process_images
+    extract_images.each do |img|
+      unless add_image_placeholder!(img)
+        limit_size!(img)
+        convert_to_link!(img)
+      end
+    end
+  end
+
   def process_inline_onebox(element)
     inline_onebox = InlineOneboxer.lookup(
       element.attributes["href"].value,
diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb
index c6f3759..4c51589 100644
--- a/spec/components/cooked_post_processor_spec.rb
+++ b/spec/components/cooked_post_processor_spec.rb
@@ -6,11 +6,7 @@ require "file_store/s3_store"
 
 describe CookedPostProcessor do
   context "#post_process" do
-    fab!(:upload) do
-      Fabricate(:upload,
-        url: '/uploads/default/original/1X/1/1234567890123456.jpg'
-      )
-    end
+    fab!(:upload) { Fabricate(:upload) }
 
     fab!(:post) do
       Fabricate(:post, raw: <<~RAW)
@@ -254,409 +250,408 @@ describe CookedPostProcessor do
         end
       end
     end
-  end
 
-  context "#post_process_images" do
-
-    before do
-      SiteSetting.responsive_post_image_sizes = ""
-    end
-
-    context "responsive images" do
-      before { SiteSetting.responsive_post_image_sizes = "1|1.5|3" }
-
-      it "includes responsive images on demand" do
-        upload = Fabricate(:upload, width: 2000, height: 1500, filesize: 10000)
-        post = Fabricate(:post, raw: "hello <img src='#{upload.url}'>")
-
-        # fake some optimized images
-        OptimizedImage.create!(
-          url: '/uploads/default/666x500.jpg',
-          width: 666,
-          height: 500,
-          upload_id: upload.id,
-          sha1: SecureRandom.hex,
-          extension: '.jpg',
-          filesize: 500,
-          version: OptimizedImage::VERSION
-        )
-
-        # fake 3x optimized image, we lose 2 pixels here over original due to rounding on downsize
-        OptimizedImage.create!(
-          url: '/uploads/default/1998x1500.jpg',
-          width: 1998,
-          height: 1500,
-          upload_id: upload.id,
-          sha1: SecureRandom.hex,
-          extension: '.jpg',
-          filesize: 800
-        )
+    context "processing images" do
+      before do
+        SiteSetting.responsive_post_image_sizes = ""
+      end
 
-        # Fake a loading image
-        optimized_image = OptimizedImage.create!(
-          url: '/uploads/default/10x10.png',
-          width: CookedPostProcessor::LOADING_SIZE,
-          height: CookedPostProcessor::LOADING_SIZE,
-          upload_id: upload.id,
-          sha1: SecureRandom.hex,
-          extension: '.png',
-          filesize: 123
-        )
+      context "responsive images" do
+        before { SiteSetting.responsive_post_image_sizes = "1|1.5|3" }
+
+        it "includes responsive images on demand" do
+          upload = Fabricate(:upload, width: 2000, height: 1500, filesize: 10000)
+          post = Fabricate(:post, raw: "hello <img src='#{upload.url}'>")
+
+          # fake some optimized images
+          OptimizedImage.create!(
+            url: '/uploads/default/666x500.jpg',
+            width: 666,
+            height: 500,
+            upload_id: upload.id,
+            sha1: SecureRandom.hex,
+            extension: '.jpg',
+            filesize: 500,
+            version: OptimizedImage::VERSION
+          )
 
-        cpp = CookedPostProcessor.new(post)
+          # fake 3x optimized image, we lose 2 pixels here over original due to rounding on downsize
+          OptimizedImage.create!(
+            url: '/uploads/default/1998x1500.jpg',
+            width: 1998,
+            height: 1500,
+            upload_id: upload.id,
+            sha1: SecureRandom.hex,
+            extension: '.jpg',
+            filesize: 800
+          )
 
-        cpp.add_to_size_cache(upload.url, 2000, 1500)
-        cpp.post_process_images
-        cpp.optimize_urls
+          # Fake a loading image
+          optimized_image = OptimizedImage.create!(
+            url: '/uploads/default/10x10.png',
+            width: CookedPostProcessor::LOADING_SIZE,
+            height: CookedPostProcessor::LOADING_SIZE,
+            upload_id: upload.id,
+            sha1: SecureRandom.hex,
+            extension: '.png',
+            filesize: 123
+          )
 
-        html = cpp.html
+          cpp = CookedPostProcessor.new(post)
 
-        expect(html).to include(%Q|data-small-upload="//test.localhost/uploads/default/10x10.png"|)
-        # 1.5x is skipped cause we have a missing thumb
-        expect(html).to include('srcset="//test.localhost/uploads/default/666x500.jpg, //test.localhost/uploads/default/1998x1500.jpg 3x"')
-        expect(html).to include('src="//test.localhost/uploads/default/666x500.jpg"')
+          cpp.add_to_size_cache(upload.url, 2000, 1500)
+          cpp.post_process
 
-        # works with CDN
-        set_cdn_url("http://cdn.localhost")
+          html = cpp.html
 
-        cpp = CookedPostProcessor.new(post)
-        cpp.add_to_size_cache(upload.url, 2000, 1500)
-        cpp.post_process_images
-        cpp.optimize_urls
+          expect(html).to include(%Q|data-small-upload="//test.localhost/uploads/default/10x10.png"|)
+          # 1.5x is skipped cause we have a missing thumb
+          expect(html).to include('srcset="//test.localhost/uploads/default/666x500.jpg, //test.localhost/uploads/default/1998x1500.jpg 3x"')
+          expect(html).to include('src="//test.localhost/uploads/default/666x500.jpg"')
 
-        html = cpp.html
+          # works with CDN
+          set_cdn_url("http://cdn.localhost")
 
-        expect(html).to include(%Q|data-small-upload="//cdn.localhost/uploads/default/10x10.png"|)
-        expect(html).to include('srcset="//cdn.localhost/uploads/default/666x500.jpg, //cdn.localhost/uploads/default/1998x1500.jpg 3x"')
-        expect(html).to include('src="//cdn.localhost/uploads/default/666x500.jpg"')
-      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, 2000, 1500)
+          cpp.post_process
 
-        cpp = CookedPostProcessor.new(post)
-        cpp.add_to_size_cache(upload.url, 200, 4000)
-        cpp.post_process_images
-        cpp.optimize_urls
+          html = cpp.html
 
-        expect(cpp.html).to_not include('srcset="')
-      end
-    end
+          expect(html).to include(%Q|data-small-upload="//cdn.localhost/uploads/default/10x10.png"|)
+          expect(html).to include('srcset="//cdn.localhost/uploads/default/666x500.jpg, //cdn.localhost/uploads/default/1998x1500.jpg 3x"')
+          expect(html).to include('src="//cdn.localhost/uploads/default/666x500.jpg"')
+        end
 
-    shared_examples "leave dimensions alone" do
-      it "doesn't use them" do
-        expect(cpp.html).to match(/src="http:\/\/foo.bar\/image.png" width="" height=""/)

[... diff too long, it was truncated ...]

GitHub sha: f54e4b71