Skip to content

Commit

Permalink
Clean up error view
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsmith committed Oct 6, 2017
1 parent 1f8a61f commit e10cf00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
17 changes: 4 additions & 13 deletions lib/code_corps_web/views/error_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@ defmodule CodeCorpsWeb.ErrorView do
use CodeCorpsWeb, :view
use JaSerializer.PhoenixView

def render("stripe-400.json-api", _assigns) do
%{
title: "This authorization code has already been used. All tokens issued with this code have been revoked.",
detail: "This authorization code has already been used. All tokens issued with this code have been revoked.",
status: "400"
}
|> JaSerializer.ErrorSerializer.format
end

def render("404.json-api", _assigns) do
%{
title: "404 Resource not found",
detail: "404 Resource not found",
title: "404 Not Found",
detail: "404 Not Found",
status: "404"
}
|> JaSerializer.ErrorSerializer.format
end

def render("500.json-api", _assigns) do
%{
title: "500 Internal server error",
detail: "500 Internal server error",
title: "500 Internal Server Error",
detail: "500 Internal Server Error",
status: "500"
}
|> JaSerializer.ErrorSerializer.format
Expand Down
6 changes: 3 additions & 3 deletions test/lib/code_corps_web/views/error_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule CodeCorpsWeb.ErrorViewTest do
rendered_json = render(CodeCorpsWeb.ErrorView, "404.json-api", [])

expected_json = %{
"errors" => [%{title: "404 Resource not found", detail: "404 Resource not found", status: "404"}],
"errors" => [%{title: "404 Not Found", detail: "404 Not Found", status: "404"}],
"jsonapi" => %{"version" => "1.0"}
}
assert rendered_json == expected_json
Expand All @@ -18,7 +18,7 @@ defmodule CodeCorpsWeb.ErrorViewTest do
rendered_json = render(CodeCorpsWeb.ErrorView, "500.json-api", [])

expected_json = %{
"errors" => [%{title: "500 Internal server error", detail: "500 Internal server error", status: "500"}],
"errors" => [%{title: "500 Internal Server Error", detail: "500 Internal Server Error", status: "500"}],
"jsonapi" => %{"version" => "1.0"}
}
assert rendered_json == expected_json
Expand All @@ -27,6 +27,6 @@ defmodule CodeCorpsWeb.ErrorViewTest do
test "render any other" do
string = render_to_string(CodeCorpsWeb.ErrorView, "505.json-api", [])

assert String.contains? string, "Internal server error"
assert String.contains? string, "Internal Server Error"
end
end

0 comments on commit e10cf00

Please sign in to comment.