Skip to content

Commit efb263e

Browse files
GRAILS-11175 - improve binding XML to non domain objects
1 parent f50ca03 commit efb263e

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

grails-test-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/GrailsWebDataBinderBindingXmlSpec.groovy

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,29 @@ class GrailsWebDataBinderBindingXmlSpec extends Specification {
9595
obj.somethings[0].name == 'One'
9696
}
9797

98-
98+
@Issue('GRAILS-11175')
99+
void 'Test binding multiple XML child elements to a List in a non domain class'() {
100+
given:
101+
def binder = new GrailsWebDataBinder(grailsApplication)
102+
def obj = new CommandObject()
103+
104+
when:
105+
def xml = new XmlSlurper().parseText("""
106+
<commandObject>
107+
<somethings>
108+
<something><name>One</name></something>
109+
<something><name>Two</name></something>
110+
</somethings>
111+
</commandObject>
112+
""")
113+
binder.bind obj, xml
114+
115+
then:
116+
!obj.hasErrors()
117+
obj.somethings?.size() == 2
118+
obj.somethings[0].name == 'One'
119+
obj.somethings[1].name == 'Two'
120+
}
99121
}
100122

101123
@Validateable

0 commit comments

Comments
 (0)