Created
October 22, 2015 20:40
-
-
Save Anonyfox/a8a7b9582f1366b6485b to your computer and use it in GitHub Desktop.
Revisions
-
Anonyfox created this gist
Oct 22, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ 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