-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The test will now only check that the favicon.ico file is redirected. Uncommented a test that was previously broken when checking for apple touch icons. It appears that in order for the tests to pass, there needs to be an entry in both routes.rb and publishing_api.rake, for example favicon.ico and apple-touch-icon.png pass (referenced in both files), but apple-touch-icon-152x152 does not (only referenced in routes.rb)
- Loading branch information
1 parent
4d9411a
commit f37d969
Showing
1 changed file
with
15 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |