在 Rails 测试中检测无限重定向
在我的 Ruby on Rails 集成测试中,我已经
assert_redirected_to buyer_deals_path(buyer)
通过了。然而,实际上它会重定向到该页面,然后以无限重定向的方式再次重定向。有什么办法可以检测到这个吗?或者更简单地说,检测它是否重定向到该页面并停留在那里(没有重定向到其他任何地方)?
In my Ruby on Rails integration test I have
assert_redirected_to buyer_deals_path(buyer)
This passes. However, in reality it redirects to that page and then redirects again in an infinite redirect. Is there anyway to detect this? Or more simply, to detect that it redirected to that page and stayed there (didn't redirect anywhere else)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在集成测试中执行此操作(我假设您是从标签中进行的),那么实际上非常简单:
我认为
follow_redirect!
仅在集成测试中可用,所以如果如果你想在功能测试中做到这一点,你将不得不寻找其他东西。If you're doing this inside an integration test (I'm assuming you are, from the tags), it's actually pretty easy:
I think
follow_redirect!
is only available in integration tests, though, so if you're trying to do this in a functional test you'll have to find something else.