我在 rspec 中有一个销毁测试,它返回以下内容:
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 运行销毁程序,但是当它被测试时,我收到了上述警告。这是为什么?
最佳答案
您的destroy
请求应该是一个AJAX 请求吗?如果是这样,您可以将 xhr
选项分配给 true。
get some_path, xhr: true
关于ruby-on-rails - Rails Rpec InvalidCrossOriginRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45823634/