gpt4 book ai didi

ruby-on-rails - Rails Rpec InvalidCrossOriginRequest

转载 作者:行者123 更新时间:2023-12-05 06:38:33 24 4
gpt4 key购买 nike

我在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com