Rails Rpec InvalidCrossOriginRequest

时间:2017-08-22 17:24:49

标签: ruby-on-rails rspec xss

我在rspec中测试了一个返回以下内容的destroy:

ActionController::InvalidCrossOriginRequest: Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.

我可以通过UI运行销毁,但是当它经过测试时,我得到了上述警告。那是为什么?

1 个答案:

答案 0 :(得分:0)

您的destroy请求应该是AJAX请求吗?如果是这样,您可以将xhr选项指定为true。

get some_path, xhr: true