Fix tests for FeedController

And remove useless Fallbacks in Fallback controller

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-04-30 14:21:33 +02:00
parent cf10e45412
commit 555620c7b0
2 changed files with 6 additions and 29 deletions

View File

@ -6,20 +6,6 @@ defmodule MobilizonWeb.FallbackController do
"""
use MobilizonWeb, :controller
def call(conn, {:error, %Ecto.Changeset{} = changeset}) do
conn
|> put_status(:unprocessable_entity)
|> put_view(MobilizonWeb.ChangesetView)
|> render("error.json", changeset: changeset)
end
def call(conn, {:error, nil}) do
conn
|> put_status(:unprocessable_entity)
|> put_view(MobilizonWeb.ErrorView)
|> render("invalid_request.json")
end
def call(conn, {:error, :not_found}) do
conn
|> put_status(:not_found)

View File

@ -3,6 +3,7 @@ defmodule MobilizonWeb.FeedController do
Controller to serve RSS, ATOM and iCal Feeds
"""
use MobilizonWeb, :controller
action_fallback(MobilizonWeb.FallbackController)
def actor(conn, %{"name" => name, "format" => "atom"}) do
with {status, data} when status in [:ok, :commit] <-
@ -12,9 +13,7 @@ defmodule MobilizonWeb.FeedController do
|> send_resp(200, data)
else
_err ->
conn
|> put_resp_content_type("text/html")
|> send_file(404, "priv/static/index.html")
{:error, :not_found}
end
end
@ -26,9 +25,7 @@ defmodule MobilizonWeb.FeedController do
|> send_resp(200, data)
else
_err ->
conn
|> put_resp_content_type("text/html")
|> send_file(404, "priv/static/index.html")
{:error, :not_found}
end
end
@ -40,9 +37,7 @@ defmodule MobilizonWeb.FeedController do
|> send_resp(200, data)
else
_err ->
conn
|> put_resp_content_type("text/html")
|> send_file(404, "priv/static/index.html")
{:error, :not_found}
end
end
@ -54,9 +49,7 @@ defmodule MobilizonWeb.FeedController do
|> send_resp(200, data)
else
_err ->
conn
|> put_resp_content_type("text/html")
|> send_file(404, "priv/static/index.html")
{:error, :not_found}
end
end
@ -68,9 +61,7 @@ defmodule MobilizonWeb.FeedController do
|> send_resp(200, data)
else
_err ->
conn
|> put_resp_content_type("text/html")
|> send_file(404, "priv/static/index.html")
{:error, :not_found}
end
end
end