从这个简单的身份验证教程
我正在寻找在:login_required管道内测试应用程序的路由(它只是检查客户端是否调用了Guardian.Plug.sign_in(conn, user))
由于user_path show动作需要通过:login_required管道传输,我原以为要测试这条路线,我只需要编写以下内容:
Auth.login_by_email_and_pass(conn, user.email, @password)
然后将由此产生的管道conn传输到:
get conn, user_path(conn, :show, user.id)
并检查我是否获得了200状态码。
但我无法越过这Auth.login_by_email_and_pass(conn, email, password)条线并得到错误:
session not fetched, call fetch_session/2
我应该在哪里获取会话?
我努力了bypass_through(conn, [:browser, :with_session])
我会认为:browser管道调用fetch_session可以解决这个问题。
我也尝试过调用fetch_session之前和之后,但仍然得到同样的错误