Rails 2.3.10 集成测试中的会话已消失

发布于 2024-10-09 07:21:25 字数 659 浏览 0 评论 0原文

在 Rails 2.3.8 中,我的集成测试(经过大量工作,并在 这篇文章)能够跨请求使用单个会话。在 Rails 2.3.10 中,该功能被破坏,登录后,后续请求没有会话。

一个可能的症状是这段代码过去可以通过:

open_session do |s|
 s.post 'login', :user=>{:user_name=>username, :password=>pass}
 assert_not_nil(s.session[:id])
end

现在却失败了(s.session[:id] 为 nil)。这可能是也可能不是问题,因为我可以确认登录操作期间存储在会话中的其他变量是否存在。然而,在后续的 s.post 中,所有操作都报告会话中没有任何内容。

有什么建议吗?我看到一份报告称 Rails 2.3.9 引入了一个会话错误,并使用 this 作为解决方法,但事实并非如此似乎有所作为。

谢谢, 汤姆

In Rails 2.3.8 my integration tests (after considerable work, and the help of this post) were able to make use of a single session across requests. In Rails 2.3.10, that functionality broke, and after logging in, subsequent requests have no session.

One possible symptom is that this bit of code used to pass:

open_session do |s|
 s.post 'login', :user=>{:user_name=>username, :password=>pass}
 assert_not_nil(s.session[:id])
end

And now it fails (s.session[:id] is nil). This may or may not be the problem, as I can confirm that other variables stored in the session during the login action are present. However on subsequent s.post's, the actions all report that there's nothing in the session.

Any advice? I saw one report that Rails 2.3.9 introduced a session bug with this as the workaround, but it doesn't appear to make a difference.

Thanks,
Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手长情犹 2024-10-16 07:21:25

您尝试过s.session.data[:id]

Did you try s.session.data[:id]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文