diff --git a/test/integration/icon_redirects_test.rb b/test/integration/icon_redirects_test.rb index b2a18591e..87413a46b 100644 --- a/test/integration/icon_redirects_test.rb +++ b/test/integration/icon_redirects_test.rb @@ -1,47 +1,23 @@ require_relative "../integration_test_helper" class IconRedirectsTest < ActionDispatch::IntegrationTest - [ - "favicon.ico", - "apple-touch-icon.png", - "apple-touch-icon-180x180.png", - "apple-touch-icon-167x167.png", - "apple-touch-icon-152x152.png", - ].each do |file| - should "redirect #{file} to the asset path" do - get "/#{file}" - 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/#{file}", last_response.location - end - - # TODO: check if this test is required and raise an issue for it - # should "redirect #{file} to a location that exists" do - # get "/assets/static/#{file}" - # assert_equal 200, last_response.status - # assert last_response.body.size > 100 - # end + 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 "ignore query string when redirecting #{file}" do - get "/#{file}?foo=bar" - assert_equal 301, last_response.status - assert_equal "http://example.org/assets/static/#{file}", 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 - [ - "apple-touch-icon-120x120.png", - "apple-touch-icon-76x76.png", - "apple-touch-icon-60x60.png", - "apple-touch-icon-precomposed.png", - ].each do |file| - should "redirect old icon size #{file} to the default apple-touch-icon.png icon" do - get "/#{file}" - 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/apple-touch-icon.png", last_response.location - 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