Hi, I’m having a Phoenix issue. I am testing a plug I wrote that calls get_session/2 at one point in order to fetch a value stored in a session. However, when the tests execute the code path that calls get_session/2, I get an error saying “Session not fetched, call fetch_session/2”. Here is the code for the plug (assume that no_login_session? is called):
and here is the code for the test.
Does anyone know how to properly call get_session/2?
You’re calling put_session...
but you’re not assigning it to the variable conn, so when you pass conn
to load_current_user
function it’s the original conn.
conn = put_session(conn(), :user_id, 1)
should work
3 Likes