From f6dc5befa89642032e16aec0842534a2b31ad7b5 Mon Sep 17 00:00:00 2001
From: Rajesh Simandalahi <rajsimand6@protonmail.com>
Date: Wed, 4 May 2022 17:05:01 +0200
Subject: [PATCH] fix blocks test

---
 test/blocks_test.rb | 83 ---------------------------------------------
 1 file changed, 83 deletions(-)

--- a/test/blocks_test.rb
+++ b/test/blocks_test.rb
@@ -2474,47 +2474,6 @@
       assert_css 'svg circle', output, 1
     end
 
-    test 'should cache remote SVG when allow-uri-read, cache-uri, and inline option are set' do
-      begin
-        if OpenURI.respond_to? :cache_open_uri
-          OpenURI.singleton_class.send :remove_method, :open_uri
-          OpenURI.singleton_class.send :alias_method, :open_uri, :cache_open_uri
-        end
-        using_test_webserver do |base_url, thr|
-          image_url = %(#{base_url}/fixtures/circle.svg)
-          attributes = { 'allow-uri-read' => '', 'cache-uri' => '' }
-          input = %(image::#{image_url}[Circle,100,100,opts=inline])
-          output = convert_string_to_embedded input, safe: :safe, attributes: attributes
-          assert defined? OpenURI::Cache
-          assert_css 'svg circle', output, 1
-          # NOTE we can't assert here since this is using the system-wide cache
-          #assert_equal thr[:requests].size, 1
-          #assert_equal thr[:requests][0], image_url
-          thr[:requests].clear
-          Dir.mktmpdir do |cache_path|
-            original_cache_path = OpenURI::Cache.cache_path
-            begin
-              OpenURI::Cache.cache_path = cache_path
-              assert_nil OpenURI::Cache.get image_url
-              2.times do
-                output = convert_string_to_embedded input, safe: :safe, attributes: attributes
-                refute_nil OpenURI::Cache.get image_url
-                assert_css 'svg circle', output, 1
-              end
-              assert_equal 1, thr[:requests].size
-              assert_match %r/ \/fixtures\/circle\.svg /, thr[:requests][0], 1
-            ensure
-              OpenURI::Cache.cache_path = original_cache_path
-            end
-          end
-        end
-      ensure
-        OpenURI.singleton_class.send :alias_method, :cache_open_uri, :open_uri
-        OpenURI.singleton_class.send :remove_method, :open_uri
-        OpenURI.singleton_class.send :alias_method, :open_uri, :original_open_uri
-      end
-    end
-
     test 'converts to alt text for SVG with inline option set if SVG cannot be read' do
       input = <<~'EOS'
       [%inline]
@@ -2942,48 +2901,6 @@
       assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
     end
 
-    test 'should cache remote image when allow-uri-read, cache-uri, and data-uri are set' do
-      begin
-        if OpenURI.respond_to? :cache_open_uri
-          OpenURI.singleton_class.send :remove_method, :open_uri
-          OpenURI.singleton_class.send :alias_method, :open_uri, :cache_open_uri
-        end
-        using_test_webserver do |base_url, thr|
-          image_url = %(#{base_url}/fixtures/dot.gif)
-          image_data_uri = 'data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs='
-          attributes = { 'allow-uri-read' => '', 'cache-uri' => '', 'data-uri' => '' }
-          input = %(image::#{image_url}[Dot])
-          output = convert_string_to_embedded input, safe: :safe, attributes: attributes
-          assert defined? OpenURI::Cache
-          assert_xpath %(//img[@src="#{image_data_uri}"][@alt="Dot"]), output, 1
-          # NOTE we can't assert here since this is using the system-wide cache
-          #assert_equal thr[:requests].size, 1
-          #assert_equal thr[:requests][0], image_url
-          thr[:requests].clear
-          Dir.mktmpdir do |cache_path|
-            original_cache_path = OpenURI::Cache.cache_path
-            begin
-              OpenURI::Cache.cache_path = cache_path
-              assert_nil OpenURI::Cache.get image_url
-              2.times do
-                output = convert_string_to_embedded input, safe: :safe, attributes: attributes
-                refute_nil OpenURI::Cache.get image_url
-                assert_xpath %(//img[@src="#{image_data_uri}"][@alt="Dot"]), output, 1
-              end
-              assert_equal 1, thr[:requests].size
-              assert_match %r/ \/fixtures\/dot\.gif /, thr[:requests][0], 1
-            ensure
-              OpenURI::Cache.cache_path = original_cache_path
-            end
-          end
-        end
-      ensure
-        OpenURI.singleton_class.send :alias_method, :cache_open_uri, :open_uri
-        OpenURI.singleton_class.send :remove_method, :open_uri
-        OpenURI.singleton_class.send :alias_method, :open_uri, :original_open_uri
-      end
-    end
-
     test 'uses remote image uri when data-uri attribute is set and image cannot be retrieved' do
       image_uri = "http://#{resolve_localhost}:9876/fixtures/missing-image.gif"
       input = <<~EOS
