-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: upgrade guardian controller to 1.7
- Loading branch information
1 parent
4c82d3e
commit 9590a23
Showing
7 changed files
with
86 additions
and
38 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
14 changes: 8 additions & 6 deletions
14
lib/bokken_web/views/admin/guardian_view.ex → ...en_web/controllers/admin/guardian_json.ex
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
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
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
19 changes: 8 additions & 11 deletions
19
lib/bokken_web/views/guardian_view.ex → lib/bokken_web/controllers/guardian_json.ex
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
48 changes: 48 additions & 0 deletions
48
test/bokken_web/controllers/admin/guardian_controller_test.exs
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
defmodule BokkenWeb.Admin.GuardianControllerTest do | ||
use BokkenWeb.ConnCase | ||
|
||
alias Bokken.Accounts | ||
|
||
import Bokken.Factory | ||
|
||
setup %{conn: conn} do | ||
password = "password1234!" | ||
guardian_user = insert(:user, role: "organizer", password: password) | ||
|
||
{:ok, user} = Accounts.authenticate_user(guardian_user.email, password) | ||
|
||
{:ok, conn: log_in_user(conn, user)} | ||
end | ||
|
||
describe "index" do | ||
test "lists all guardians", %{conn: conn} do | ||
conn = get(conn, ~p"/api/admin/guardians/") | ||
assert json_response(conn, 200)["data"] == [] | ||
end | ||
end | ||
|
||
describe "show" do | ||
test "shoes", %{conn: conn} do | ||
guardian = insert(:guardian) | ||
|
||
update_attrs = %{ | ||
mobile: "+351915096743", | ||
first_name: "Ana Maria", | ||
last_name: "Silva Costa", | ||
city: "Guimarães" | ||
} | ||
|
||
user_params = %{ | ||
user_id: guardian.user_id | ||
} | ||
|
||
conn = | ||
put(conn, ~p"/api/admin/guardians/#{guardian.id}", %{ | ||
guardian: update_attrs, | ||
user: user_params | ||
}) | ||
|
||
assert %{"id" => _id} = json_response(conn, 200)["data"] | ||
end | ||
end | ||
end |
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