简体   繁体   English

Grails 2.0.0:HTTP状态302

[英]Grails 2.0.0: HTTP status 302

I have a controller which allows only POST for certain actions: 我有一个仅允许POST进行某些操作的控制器:

static allowedMethods = [save: "POST", update: "POST", delete: "POST"]

Then there's a test for it: 然后有一个测试:

void testUpdateWithGet() {
    controller.update()
    assert response.status == HttpServletResponse.SC_METHOD_NOT_ALLOWED
} 

This worked fine with 2.0.0.RC1 but after upgrading to Grails 2.0.0 final release the returned status in the response is 302 . 在2.0.0.RC1上可以正常工作,但是在升级到Grails 2.0.0最终版本后,响应中的返回状态为302 Why is that? 这是为什么?

Regards 问候

Jonas 乔纳斯

I can confirm your test case. 我可以确认您的测试用例。 It's because since 2.0.0.RC3 Grails has unresolved bug that affects 2.0.0 final too: http://jira.grails.org/browse/GRAILS-8426 - Allowed methods are not respected in unit tests. 这是因为自从2.0.0.RC3以来,Grails也存在未解决的bug,也影响了2.0.0 final: http : //jira.grails.org/browse/GRAILS-8426-单元测试中未遵循允许的方法。 You can downgrade to 2.0.0.RC1 or wait for this bug to be fixed. 您可以降级到2.0.0.RC1或等待此错误被修复。 It only affects unit tests, but works fine in application. 它仅影响单元测试,但在应用程序中运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM