   @opts Api.Router.init([])
 
   test "get document" do
-    conn = conn(:get, "/documents/doc-of-proj-a")
-    conn = Api.Router.call(conn, @opts)
-    doc = Core.Utils.atomize(Poison.decode!(conn.resp_body))
+    {conn, doc} = get_doc "doc-of-proj-a"
 
     assert conn.state == :sent
     assert conn.status == 200

  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))

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

  end

  test "show rights" do
    assert show_rights("user-1", "pass-1") == ["a", "b", "c", "d"]
    assert show_rights("user-2", "pass-2") == ["a", "b", "c"]
    assert show_rights("user-3", "pass-3") == ["a", "b"]
  end

  defp sign_in name, pass do
