   end
 
   test "get document as logged in user" do
-    token = sign_in "user-1", "pass-1"
-    conn = conn(:get, "/documents/doc-of-proj-b")
-           |> put_req_header("authorization", token)
-           |> Api.Router.call(@opts)
-    doc = Core.Utils.atomize(Poison.decode!(conn.resp_body))
+    {conn, doc} = get_doc "doc-of-proj-b", "user-1", "pass-1"
 
     assert conn.state == :sent
     assert conn.status == 200

    Poison.decode!(conn.resp_body)["token"]
  end

  defp show_rights token do
    conn = conn(:get, "/auth/show")
      |> put_req_header("authorization", token)
      |> Api.Router.call(@opts)

    Core.Utils.atomize(Poison.decode!(conn.resp_body)).rights.readable_projects
  end
end
  @opts Api.Router.init([])

  test "get document" do
    {conn, doc} = get_doc "doc-of-proj-a"

    assert conn.state == :sent
    assert conn.status == 200
