Skip to content

Commit 268e386

Browse files
committed
Add test to reproduce Issue #13945
1 parent 874f552 commit 268e386

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

grails-test-suite-web/src/test/groovy/org/grails/web/commandobjects/CommandObjectsSpec.groovy

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import grails.testing.gorm.DataTest
55
import grails.testing.web.controllers.ControllerUnitTest
66
import grails.validation.Validateable
77
import spock.lang.Issue
8+
import spock.lang.PendingFeature
89
import spock.lang.Specification
910

1011
class CommandObjectsSpec extends Specification implements ControllerUnitTest<TestController>, DataTest {
@@ -304,6 +305,37 @@ class CommandObjectsSpec extends Specification implements ControllerUnitTest<Tes
304305
commandObject.firstName == 'Douglas'
305306
commandObject.lastName == 'Mendes'
306307
}
308+
309+
@Issue('https://github.com/grails/grails-core/issues/13945')
310+
void "calling actions involving inherited command objects - child command"() {
311+
given:
312+
params.testId = 1
313+
params.myId = 3
314+
params.pId = 2
315+
316+
when:
317+
def model = controller.zMethodTakingChild()
318+
def commandObject = model.commandObject
319+
320+
then:
321+
commandObject.testId == 1
322+
commandObject.myId == 3
323+
model.pId == 2
324+
}
325+
326+
@PendingFeature()
327+
@Issue('https://github.com/grails/grails-core/issues/13945')
328+
void "calling actions involving inherited command objects - parent command"() {
329+
given:
330+
params.testId = 1
331+
332+
when:
333+
def model = controller.methodTakingParent()
334+
def commandObject = model.commandObject
335+
336+
then:
337+
commandObject.testId == 1
338+
}
307339
}
308340

309341
@Artefact('Controller')
@@ -362,6 +394,23 @@ class TestController {
362394
def methodActionWithGenericBasedCommand(ConcreteGenericBased co) {
363395
[commandObject: co]
364396
}
397+
398+
def zMethodTakingChild(ChildCommand command, long pId) {
399+
[commandObject: command, pId: pId]
400+
}
401+
402+
def methodTakingParent(ParentCommand command) {
403+
[commandObject: command, pId: 2]
404+
}
405+
}
406+
407+
408+
class ParentCommand {
409+
int testId
410+
}
411+
412+
class ChildCommand extends ParentCommand {
413+
int myId
365414
}
366415

367416
class DateComamndObject {

0 commit comments

Comments
 (0)