Skip to content

Commit

Permalink
add default_user() to support/test_helpers.ex p.293 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Aug 11, 2019
1 parent c20e5e4 commit d5489ec
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apps/rumbl_web/test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(Rumbl.Repo, :manual)

defmodule RumblWeb.TestHelpers do

defp default_user() do
%{
name: "Some User",
username: "user#{System.unique_integer([:positive])}",
password: "supersecret"
}
end

def insert_user(attrs \\ %{}) do
{:ok, user} =
attrs
|> Enum.into(default_user())
|> Rumbl.Accounts.register_user
end
end

0 comments on commit d5489ec

Please sign in to comment.