Skip to content

Commit

Permalink
test(controllers/board): mix format
Browse files Browse the repository at this point in the history
  • Loading branch information
unenglishable committed Nov 6, 2023
1 parent 57bc64d commit 5855fd9
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions test/epochtalk_server_web/controllers/board_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ defmodule Test.EpochtalkServerWeb.Controllers.Board do

describe "by_category/2" do
@tag authenticated: :private
test "when authenticated with invalid permissions, raises InvalidPermission error", %{conn: conn} do
test "when authenticated with invalid permissions, raises InvalidPermission error", %{
conn: conn
} do
assert_raise InvalidPermission,
~r/^Forbidden, invalid permissions to perform this action/,
fn ->
get(conn, Routes.board_path(conn, :by_category))
end
end

test "finds all active boards", %{
conn: conn,
category: category,
Expand Down Expand Up @@ -138,7 +141,10 @@ defmodule Test.EpochtalkServerWeb.Controllers.Board do
assert response["message"] == "Error, board does not exist"
end

test "when unauthenticated, given an existing id above read access, errors", %{conn: conn, admin_board: admin_board} do
test "when unauthenticated, given an existing id above read access, errors", %{
conn: conn,
admin_board: admin_board
} do
response =
conn
|> get(Routes.board_path(conn, :find, admin_board.id))
Expand All @@ -148,7 +154,10 @@ defmodule Test.EpochtalkServerWeb.Controllers.Board do
assert response["message"] == "Board not found"
end

test "when unauthenticated, given an existing id within read access, finds a board", %{conn: conn, parent_board: board} do
test "when unauthenticated, given an existing id within read access, finds a board", %{
conn: conn,
parent_board: board
} do
response =
conn
|> get(Routes.board_path(conn, :find, board.id))
Expand All @@ -166,7 +175,10 @@ defmodule Test.EpochtalkServerWeb.Controllers.Board do
end

@tag :authenticated
test "when authenticated, given an existing id above read access, errors", %{conn: conn, admin_board: admin_board} do
test "when authenticated, given an existing id above read access, errors", %{
conn: conn,
admin_board: admin_board
} do
response =
conn
|> get(Routes.board_path(conn, :find, admin_board.id))
Expand All @@ -177,7 +189,10 @@ defmodule Test.EpochtalkServerWeb.Controllers.Board do
end

@tag :authenticated
test "when authenticated, given an existing id at read access, finds board", %{conn: conn, parent_board: board} do
test "when authenticated, given an existing id at read access, finds board", %{
conn: conn,
parent_board: board
} do
response =
conn
|> get(Routes.board_path(conn, :find, board.id))
Expand All @@ -187,7 +202,10 @@ defmodule Test.EpochtalkServerWeb.Controllers.Board do
end

@tag authenticated: :admin
test "when authenticated as admin, given an existing id at read access, finds board", %{conn: conn, admin_board: admin_board} do
test "when authenticated as admin, given an existing id at read access, finds board", %{
conn: conn,
admin_board: admin_board
} do
response =
conn
|> get(Routes.board_path(conn, :find, admin_board.id))
Expand All @@ -197,7 +215,10 @@ defmodule Test.EpochtalkServerWeb.Controllers.Board do
end

@tag authenticated: :admin
test "when authenticated as admin, given an existing id above read access, errors", %{conn: conn, super_admin_board: super_admin_board} do
test "when authenticated as admin, given an existing id above read access, errors", %{
conn: conn,
super_admin_board: super_admin_board
} do
response =
conn
|> get(Routes.board_path(conn, :find, super_admin_board.id))
Expand All @@ -208,7 +229,10 @@ defmodule Test.EpochtalkServerWeb.Controllers.Board do
end

@tag authenticated: :super_admin
test "when authenticated as super admin, given an existing id at read access, finds board", %{conn: conn, super_admin_board: super_admin_board} do
test "when authenticated as super admin, given an existing id at read access, finds board", %{
conn: conn,
super_admin_board: super_admin_board
} do
response =
conn
|> get(Routes.board_path(conn, :find, super_admin_board.id))
Expand Down

0 comments on commit 5855fd9

Please sign in to comment.