   end
 
   test "PUT returns an error if any attributes are invalid", %{conn: conn} do
-    {:ok, calendar} = Repo.insert(%Calendar{})
+    {:ok, calendar} = Calendars.create_calendar()
 
     attrs = %{title: String.duplicate("x", 101)}
     conn = put conn, calendar_path(conn, :update, calendar), attrs

    conn = post conn, calendar_path(conn, :create), %{}
    body = json_response(conn, 201)

    calendar = Repo.get(Calendar, body["id"])
    assert calendar

    location = Conn.get_resp_header(conn, "location") |> List.first

  use CalgyApi.ConnCase

  alias Plug.Conn
  alias Calgy.Calendars

  setup %{conn: orig_conn} do
    conn = put_req_header(orig_conn, "accept", "application/json")
    {:ok, %{conn: conn}}
  end

