From 153175d67629694f3cee99ac646c09b7183ae7cb Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 2 Sep 2024 21:37:49 +0200 Subject: [PATCH] DEV: removes unused intergation.rake (#28687) This is dead code which won't even run. --- lib/tasks/integration.rake | 48 -------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 lib/tasks/integration.rake diff --git a/lib/tasks/integration.rake b/lib/tasks/integration.rake deleted file mode 100644 index 66a122841d3..00000000000 --- a/lib/tasks/integration.rake +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -require "open-uri" - -desc "Creates the integration fixtures. Requires a development instance running." -task "integration:create_fixtures" => :environment do - fixtures = { - discovery: %w[/latest.json /categories.json /c/bug/l/latest.json], - topic: ["/t/280.json"], - user: %w[/u/eviltrout.json /user_actions.json /topics/created-by/eviltrout.json], - static: %w[/faq /tos /privacy], - unknown: ["/404-body"], - } - - fixtures.each do |type, urls| - filename = "#{Rails.root}/test/javascripts/fixtures/#{type}_fixtures.js" - - content = "export default {\n" - urls.each do |url| - http_result = fake_xhr("http://localhost:3000#{url}") - - # If the result is not JSON, convert it to JSON - begin - parsed = ::JSON.parse(http_result) - rescue StandardError - http_result = http_result.to_json - end - content << "\"#{url}\": #{http_result},\n" - end - content << "};\n" - - File.write(filename, content) - end -end - -def fake_xhr(url) - uri = URI(url) - - result = nil - Net::HTTP.start(uri.host, uri.port) do |http| - request = Net::HTTP::Get.new uri - request.add_field "X-Requested-With", "XMLHttpRequest" - response = http.request(request) - result = response.body.force_encoding("UTF-8") - end - - result -end