#--- # Excerpted from "Programming Phoenix", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/phoenix for more book information. #--- defmodule Rumbl.AuthTest do use Rumbl.ConnCase alias Rumbl.Auth test "authenticate_user halts when no current_user exists", %{conn: conn} do conn = Auth.authenticate_user(conn, []) assert conn.halted end test "authenticate_user continues when the current_user exists", %{conn: conn} do conn = conn |> assign(:current_user, %Rumbl.User{}) |> Auth.authenticate_user([]) refute conn.halted end end