Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

40 行
845B

  1. defmodule Pleroma.Plugs.SetUserSessionIdPlugTest do
  2. use Pleroma.Web.ConnCase, async: true
  3. alias Pleroma.Plugs.SetUserSessionIdPlug
  4. alias Pleroma.User
  5. setup %{conn: conn} do
  6. session_opts = [
  7. store: :cookie,
  8. key: "_test",
  9. signing_salt: "cooldude"
  10. ]
  11. conn =
  12. conn
  13. |> Plug.Session.call(Plug.Session.init(session_opts))
  14. |> fetch_session
  15. %{conn: conn}
  16. end
  17. test "doesn't do anything if the user isn't set", %{conn: conn} do
  18. ret_conn =
  19. conn
  20. |> SetUserSessionIdPlug.call(%{})
  21. assert ret_conn == conn
  22. end
  23. test "sets the user_id in the session to the user id of the user assign", %{conn: conn} do
  24. conn =
  25. conn
  26. |> assign(:user, %User{id: 1})
  27. |> SetUserSessionIdPlug.call(%{})
  28. id = get_session(conn, :user_id)
  29. assert id == 1
  30. end
  31. end