我升级我的Rails应用程序5现在,目前克服以下弃用:测试redirect_back使用RSpec Rails中5
DEPRECATION WARNING: `redirect_to :back` is deprecated and will be removed from Rails 5.1. Please use `redirect_back(fallback_location: fallback_location)` where `fallback_location` represents the location to use if the request has no HTTP referer information. (called from block (3 levels) in <top (required)> at /path/to/some/controller_spec.rb:74)
无后顾之忧。刚换控制器到新的格式:
redirect_back(fallback_location: home_path, message: "Some error")
然而,警告将不会消失,因为测试仍然看:back
,像这样:
expect(response).to redirect_to(:back)
我没有看到任何首选克服这种折旧的方法。有没有另一种方法来测试这个没有在我的测试中手动指定HTTP_REFERER
?
同意了,我的测试中实际处理这件事到现在为止:d –