defmodule N3ws.ChannelControllerTest do import Plug.Conn, only: [assign: 3] @valid_attrs %{name: "some content"} @invalid_attrs %{} @user_attrs %{ email: "some content", name: "some content", password_virtual: "some content" } setup do user = Repo.insert!(User.registration_changeset(%User{}, @user_attrs)) conn = assign(conn(), :current_user, user) {:ok, conn: conn} end test "creates resource and redirects when data is valid", %{conn: conn} do attrs = %{@valid_attrs | user_id: conn.assigns.current_user.id} conn = post conn, channel_path(conn, :create), channel: attrs assert redirected_to(conn) == channel_path(conn, :index) assert Repo.get_by(Channel, attrs) end end