[英]How can I get the value in a hash of the response of POST request on Ruby?
[英]When I write a functional test in Ruby on Rails, I get a 403 response to a GET/POST request
我正在尝试通过我的功能测试创建一个新用户,但未创建该用户。 assert_no_difference('User.count') 结果失败。
发布部分测试:post:create, :user => {:client_id => 'xxxx', :client_secret => 'yyyy', :email => 'anp@random.com', :password => 'testpass' }
我得到这个 output: 1) 失败: test_should_allow_bare_signup(UsersControllerTest) []: 预期响应是 <:success>,但是是 <403>
2) 失败:test_should_allow_full_signup(UsersControllerTest) []: "User.count" 没有改变 1。 <4> 预期但为 <3>。
我觉得测试无法访问 users_controller,因此导致 403 Forbidden。
这是因为在您的 users_controller 上创建的操作需要执行身份验证。
您使用哪种身份验证?
解决方案应该是在提交您的帖子之前执行访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.