lint
This commit is contained in:
parent
5f321b0b5b
commit
3760480813
2 changed files with 6 additions and 5 deletions
|
|
@ -30,6 +30,7 @@ defmodule Pleroma.Web.Plugs.FaviconPlug do
|
||||||
# Favicon should always be available and this should never occur.
|
# Favicon should always be available and this should never occur.
|
||||||
# If it does, halt the pipeline before having unintended side-effects.
|
# If it does, halt the pipeline before having unintended side-effects.
|
||||||
Logger.error("No favicon.png found! Is the default favicon deleted?")
|
Logger.error("No favicon.png found! Is the default favicon deleted?")
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> send_resp(404, "Not found")
|
|> send_resp(404, "Not found")
|
||||||
|> halt()
|
|> halt()
|
||||||
|
|
@ -40,7 +41,7 @@ defmodule Pleroma.Web.Plugs.FaviconPlug do
|
||||||
conn
|
conn
|
||||||
end
|
end
|
||||||
|
|
||||||
defp find_favicon_dir() do
|
defp find_favicon_dir do
|
||||||
instance_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static")
|
instance_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static")
|
||||||
instance_path = Path.join(instance_dir, "favicon.png")
|
instance_path = Path.join(instance_dir, "favicon.png")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ defmodule Pleroma.Web.Plugs.FaviconPlugTest do
|
||||||
@dir "test/tmp/favicon_static"
|
@dir "test/tmp/favicon_static"
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
Pleroma.Backports.mkdir_p!(@dir)
|
Pleroma.Backports.mkdir_p!(@dir)
|
||||||
|
|
||||||
on_exit(fn -> File.rm_rf!(@dir) end)
|
on_exit(fn -> File.rm_rf!(@dir) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "default favicon" do
|
describe "default favicon" do
|
||||||
|
|
@ -48,12 +48,12 @@ defmodule Pleroma.Web.Plugs.FaviconPlugTest do
|
||||||
body_size = byte_size(conn.resp_body)
|
body_size = byte_size(conn.resp_body)
|
||||||
|
|
||||||
assert conn.status == 200
|
assert conn.status == 200
|
||||||
assert body_size == 104426
|
assert body_size == 104_426
|
||||||
assert response_content_type(conn, :png)
|
assert response_content_type(conn, :png)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns correct cache-control", %{conn: conn} do
|
test "returns correct cache-control", %{conn: conn} do
|
||||||
conn = get(conn ,"/favicon.png")
|
conn = get(conn, "/favicon.png")
|
||||||
cache = get_resp_header(conn, "cache-control")
|
cache = get_resp_header(conn, "cache-control")
|
||||||
|
|
||||||
assert conn.status == 200
|
assert conn.status == 200
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue