Skip to content

Instantly share code, notes, and snippets.

@blacksails
Last active September 9, 2015 08:24
Show Gist options
  • Save blacksails/1a064b2ca91b54f9a101 to your computer and use it in GitHub Desktop.
Save blacksails/1a064b2ca91b54f9a101 to your computer and use it in GitHub Desktop.
# Test looks like this
test "call should set current_user to nil if auth fails" do
conn = post(conn, auth_path(conn, :login),
auth: %{@credentials | password: "cheesesticks"})
conn = VerifySession.call(conn, [])
refute conn.private.current_user
end
# This is what happens at the endpoint:
conn
# If i comment in the following two lines, the test passes else it doesn't
# |> fetch_session
# |> put_session(:token, nil)
|> put_status(Status.code(:unauthorized))
|> render("error.json", msg: "invalid email or password")
# Verify session does this:
conn
|> fetch_session # Plug.Conn.AlreadySentError raised on this line
|> get_token
|> verify_token
|> assign_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment