Grails:使用多个/前缀参数进行集成测试,例如 (params[“book”])
我在 nabble 此处
我正在尝试在控制器集成测试中发送参数或不同的域。 但无法让它们绑定到带有“book”前缀的域类
//正在测试的控制器操作
def saveBook = {
def book = new Book()
bindData(book, params["book"], [include: ['publicPrivacy', 'description', 'title'])
}
//集成测试 -
def bookController = BookContoller()
//Doesn't Bind
bookController.params.publicPrivacy = false
bookController.params.description = "Best book in the world"
bookController.params.title = "The world"
bookController.params.book.publicPrivacy = false
bookController.params.book.description = "Best book in the world"
bookController.params.book.title = "The world"
bookController.params["book"].publicPrivacy = false
bookController.params.[book.description] = "Best book in the world"
bookController.saveBook()
我如何设置带有要发送到控制器的前缀的“params”以便它们绑定到域?
I've asked the exact same question on nabble here
I'm trying to send params or different domains in the controller integration test.
But can't get them to bind to the domain class with the prefix of "book"
//Controller action being tested
def saveBook = {
def book = new Book()
bindData(book, params["book"], [include: ['publicPrivacy', 'description', 'title'])
}
//Integration Test -
def bookController = BookContoller()
//Doesn't Bind
bookController.params.publicPrivacy = false
bookController.params.description = "Best book in the world"
bookController.params.title = "The world"
bookController.params.book.publicPrivacy = false
bookController.params.book.description = "Best book in the world"
bookController.params.book.title = "The world"
bookController.params["book"].publicPrivacy = false
bookController.params.[book.description] = "Best book in the world"
bookController.saveBook()
how do i set the "params" with the prefix to be sent to the controller so they bind to the domain?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使参数命名空间正常工作,我必须使用
org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap
用于 params 对象。例如:For params namespacing to work, I've had to use a
org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap
for the params object. For example: