Created
August 20, 2016 23:35
-
-
Save younesmln/fe4a55ce9d2af796f99c75943c5768cd to your computer and use it in GitHub Desktop.
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
defmodule Trello.AuthControllerTest do | |
use Trello.ConnCase | |
alias Trello.User | |
@valid_attrs %{email: "[email protected]", f_name: "younes", l_name: "some content", password: "1234"} | |
setup %{conn: conn} do | |
{:ok, conn: put_req_header(conn, "accept", "application/json")} | |
end | |
test "login with invalid informations", %{conn: conn} do | |
credentials = %{login: "user.email", password: "dummy"} | |
conn = post(conn, auth_path(conn, :create), user: credentials) | |
assert json_response(conn, :unprocessable_entity) == Trello.AuthView.render("error.json") | |
end | |
test "login with valid informations and get a token", %{conn: conn} do | |
user = User.changeset(%User{}, @valid_attrs) |> Repo.insert! | |
credentials = %{login: user.email, password: user.password} | |
conn = post(conn, auth_path(conn, :create), user: credentials) | |
assert json_response(conn, 200)["token"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment