From 56effaad5be76b013a15e2f3737f1aecf3d18445 Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Wed, 25 Sep 2024 13:19:42 +0100 Subject: [PATCH] Remove favicon route support - Favicon route now supported by Frontend - Remove publishing_api task --- app/controllers/icon_redirects_controller.rb | 9 ------ config/routes.rb | 3 -- lib/tasks/publishing_api.rake | 34 -------------------- test/integration/icon_redirects_test.rb | 23 ------------- 4 files changed, 69 deletions(-) delete mode 100644 app/controllers/icon_redirects_controller.rb delete mode 100644 lib/tasks/publishing_api.rake delete mode 100644 test/integration/icon_redirects_test.rb diff --git a/app/controllers/icon_redirects_controller.rb b/app/controllers/icon_redirects_controller.rb deleted file mode 100644 index 36c6d202e..000000000 --- a/app/controllers/icon_redirects_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class IconRedirectsController < ApplicationController - before_action { expires_in(1.day, public: true) } - - def show_favicon - redirect_to(view_context.asset_path("favicon.ico"), - status: :moved_permanently, - allow_other_host: true) - end -end diff --git a/config/routes.rb b/config/routes.rb index 476927f0d..d28182ead 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,7 +14,4 @@ get "/templates/:template.html.erb", to: "root#template" end - - # Favicon redirect - get "/favicon.ico", to: "icon_redirects#show_favicon" end diff --git a/lib/tasks/publishing_api.rake b/lib/tasks/publishing_api.rake deleted file mode 100644 index babbec4cc..000000000 --- a/lib/tasks/publishing_api.rake +++ /dev/null @@ -1,34 +0,0 @@ -ROUTES = [ - { - base_path: "/favicon.ico", - content_id: "5fc8b4bc-f899-4d4e-ae10-f9beeb172f50", - title: "Favicon", - description: "The favicon is the image displayed in locations such as the browser tabs.", - }, -].freeze - -namespace :publishing_api do - desc "Publish special routes such as humans.txt" - task publish_special_routes: :environment do - require "gds_api/publishing_api/special_route_publisher" - - publisher = GdsApi::PublishingApi::SpecialRoutePublisher.new( - logger: Logger.new($stdout), - publishing_api: GdsApi.publishing_api, - ) - - ROUTES.each do |route| - publisher.publish( - route.merge( - document_type: "special_route", - schema_name: "special_route", - type: "exact", - publishing_app: "static", - rendering_app: "static", - public_updated_at: Time.zone.now.iso8601, - update_type: "major", - ), - ) - end - end -end diff --git a/test/integration/icon_redirects_test.rb b/test/integration/icon_redirects_test.rb deleted file mode 100644 index 87413a46b..000000000 --- a/test/integration/icon_redirects_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require_relative "../integration_test_helper" - -class IconRedirectsTest < ActionDispatch::IntegrationTest - should "redirect `favicon.ico` to the asset path" do - get "/favicon.ico" - assert_equal 301, last_response.status - assert_equal last_response.headers["Cache-Control"], "max-age=86400, public" - # In development and test mode the asset pipeline doesn't add the hashes to the URLs - assert_equal "http://example.org/assets/static/favicon.ico", last_response.location - end - - should "redirect `favicon.ico` to a location that exists" do - get "/assets/static/favicon.ico" - assert_equal 200, last_response.status - assert last_response.body.size > 100 - end - - should "ignore query string when redirecting `favicon.ico`" do - get "/favicon.ico?foo=bar" - assert_equal 301, last_response.status - assert_equal "http://example.org/assets/static/favicon.ico", last_response.location - end -end