Skip to content

Testing with Coherence

Steve Pallen edited this page Nov 27, 2016 · 1 revision

The following shows how to test protected resources.

defmodule MyApp.PostControllerTest do
  use MyApp.ConnCase

  setup %{conn: conn} do
    user = User.changeset(%User{}, %{name: "test", email: "[email protected]", password: "test", password_confirmation: "test"})
    |> Repo.insert!
    {:ok, conn: assign(conn, :current_user, user), user: user}
  end

  test "lists all entries on index", %{conn: conn} do
    conn = get conn, post_path(conn, :index)
    assert html_response(conn, 200) =~ "Listing posts"
  end
end
Clone this wiki locally