rspec request redirect_back
By admin
(ActionController::RedirectBackError) “No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify
之前一直没写request的测试,最近升级rails4.0出错的地方挺多,决定还是把这方面的测试弄上好踏实点。
当测试请求一个页面redirect_to :back时,可以用referer参数模拟,要放在模拟表单参数的后面。如果没有表单的参数也需要用一个{}来占位。
put “/post/1”, post: {title: ‘abc’}, {referer: ‘/posts’}